13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 4 ■ TAKING BACKUPS AND MANAGING DATA■ Note If you don’t want to have LDAP offline, you can use a slave server (see recipe 2-7) and either run thebackup off that or rely on the slave to pick up any LDAP requests that come in the interim.Finally, line 13 deletes any files in the backup directory that are more than 14 days old, whichprevents you from ending up with enormous stacks of old LDIF files. Line 14 copies the backup directoryto a shared directory on a different machine (here mounted as /shared/raid/server_backups). Thus, ifyour LDAP machine crashes altogether, you don’t lose the backup directory as well.Putting the script in /etc/cron.daily/ means it will automatically be run once a day (the default isfor this to happen overnight). Make sure it’s root-owned and executable (note also that the name needsto have no extension, as shown here, or it won’t be run by run-parts):chown root:root /etc/cron.daily/ldapbackupchmod u+rx /etc/cron.daily/ldapbackupFor Kerberos backup, save this script as /etc/cron.daily/krbbackup:01 #!/bin/sh02 dir="/usr/local/backups/kerberos/"03 file="kerbdumpfile"04 server="raidserver:/raid"05 mntdir="/mnt/"06 remotedir="server_backups/"07 mount -t nfs $server $mnt08 kdb5_util dump $dir$file09 cp $dir$file $mntdir$remotedir10 umount $mntdirAgain, lines 02–06 set up the variables. Line 07 mounts the remote server. You can use this method ifyou don’t want the NFS remote directory to be permanently mounted, or automounted, on the Kerberosserver. (You can make a similar change to the earlier LDAP backup script, if you prefer.)Line 08 dumps the Kerberos database using kdb5_util dump, and lines 09–10 copy the dump fileacross to the remote server and then unmount it.Again, make sure the script is root-owned and executable:chown root:root /etc/cron.daily/krbbackupchmod u+rx /etc/cron.daily/krbbackup4-6. Performing a Rapid Restore with Automated rsyncOne problem with a tape backup solution is that in the event of some kind of catastrophic data loss(machine or drive failure, for example), tapes can take quite some time to restore, especially for largedrives.It’s therefore a good idea to have, as well as your tape backups, some kind of mirror of importantdirectories. Obviously, if you have a RAID 0 machine, you have this automatically, but if you don’t (or if104Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!