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 DATAyou would prefer that your mirror be on another machine or even at another site), you can set up yourown mirroring with rsync.In this case, let’s look at the case of a shared home directory at homeserver:/shared/home.The basic rsync command is as follows:rsync /dir/source /dir/destinationThis compares the two directories and copies across any files in /dir/source that are newer thanthose in /dir/destination. So, the first time it’s run, it will copy everything (and may take some time);thereafter, it copies only what has changed, thus saving both time and network capacity.That basic command synchronizes from one local directory to another local directory, but in fact/dir/destination can be on another machine:rsync /dir/source machinename.example.com:/dir/destination■ Note You can also reverse this:rsync machinename.example.com:/dir/source /dir/destinationwhich is useful for restore.rsync has numerous options, but these are the most useful ones:• -a: Archive, which both recurses over the directory structure and keeps fileattributes (ownership, permissions, edit times, and so on) intact.• -u: Update, which does not update any files that are newer on the destinationdirectory than on the source.• -z: Compress, which compresses during the transfer.• -v: Verbose, so you can follow what’s happening.• -L: Follow symlinks, copying the files that they point to in full, rather than usingthe default option of recording them as symlinks.• --delete: Deletes from the destination directory files that no longer exist on thesource directory.• -n: Does a dummy run but doesn’t actually transfer any files (useful with -v whentesting).So, if you have a backup drive available at backupserver:/shared/backuphome, you can back up yourshared home directory like this, logged in as root on homeserver:rsync -avuz /shared/home backupserver:/shared/backuphome105Download at WoweBook.Com

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

Saved successfully!

Ooh no, something went wrong!