SmbLdapDisasterRecovery

smbldaplogo.png

The Backup Situation

The smbldap installer asks you the following questions about LDAP database backups:

  1. How often do you want your LDAP database backed up?
  2. How often do you want your backup files rotated?
  3. How many rotated backup files do you wish to keep?
  4. In which directory do you want the LDIF backups to be stored?

The default answers will configure your system to back your LDAP database up daily (using slapcat), rotate the backup weekly, retain eight rotated backups before overwriting, and store this all in /var/lib/ldap/ldif-backups, or, starting with smbldap-installer-2.0.1, in /var/smbldap-backups.

For example, a listing of your backup directory may look like this if you keep the default options:

root@test7:/var/smbldap-backups # ls -l
total 100
-rw-r--r-- 1 root root 44061 2006-04-25 18:15 smbldap.ldif
-rw-r--r-- 1 root root  5033 2006-04-23 18:15 smbldap.ldif.1.gz
-rw-r--r-- 1 root root  5033 2006-04-16 18:15 smbldap.ldif.2.gz
-rw-r--r-- 1 root root  5033 2006-04-09 18:15 smbldap.ldif.3.gz
-rw-r--r-- 1 root root  5033 2006-04-02 18:15 smbldap.ldif.4.gz
-rw-r--r-- 1 root root  4138 2006-03-26 18:15 smbldap.ldif.5.gz
-rw-r--r-- 1 root root  3217 2006-03-19 18:15 smbldap.ldif.6.gz
-rw-r--r-- 1 root root  2823 2006-03-12 18:15 smbldap.ldif.7.gz
root@test7:/var/lib/ldap/ldif-backups #

It is a good idea to mount an external volume (better yet, remotely mount an offsite-volume over the network) for this directory, so that a catastrophic server failure (such as a HDD failure) doesn't destroy both your active database and your backups in one fell swoop.

And of course you should have a backup solution in place for all the home directories stored on your server, as well.

Disaster Recovery

First, make sure you can restore all your home directories and user data. Tools such as rsync, tar, or cpio work nicely for this, and in any case be sure your preserve ownership and permissions!

If you have a failure that destroys your database, or if you wish to move to a new or upgraded server for whatever reason, then you really want to know about the slapadd command.

Use an Old Database on a Newly-Installed Server

If you've configured a new (or "fresh") server and you wish to use an old database, it's best to install the new OS, run the smbldap installer (preferably before your do system updates), 'give the same answers to all the smbldap-installer questions as you did the first time', and then follow the same procedure below as someone recovering from a corrupt database.

Use Backup to Recover From a Corrupt Database

  • New! Use the smbldap-restore script (download smbldap-installer-3.1 or later) to do the following for you. For example:

    • $ ./smbldap-restore /var/smbldap-backups/smbldap.ldif
    • smbldap-restore can be used even if you installed using an older version of the smbldap-installer.

Here's what smbldap-restore does:

  1. Remove the existing database files entirely. These are usually stored in /var/lib/ldap.
  2. Locate the LDIF backup file you are going to use; our example will use /var/smbldap-backups/smbldap.ldif.
  3. Use the slapadd command to read the LDIF backup into your live database:

$ slapadd < /var/smbldap-backups/smbldap.ldif
  1. Then restart the LDAP and Samba services (and NSCD if you're using it). The following should do the trick, but keep in mind that sometimes the Samba service is called "samba" and sometimes it's "smb", and sometimes the LDAP service is named "ldap" and sometimes it's "slapd", etc...

$ /etc/init.d/smb restart
$ /etc/init.d/slapd restart

You should be all set!

SmbLdapDisasterRecovery (last edited 2008-08-06 16:30:06 by localhost)