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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4 ■ TAKING BACKUPS AND MANAGING DATATo specify which key the rsync command should use, run the following:rsync -avuz -e "ssh -i /home/user/.ssh/rsync" /test \user@offsite.example.com:/home/user/backupThis line must match the command you put in the previous ~/.ssh/authorized_keys2 file, oroffsite.example.com will refuse your access. You should see output indicating rsync connecting via sshwithout a password prompt, building the filelist, and then updating with any changes.4-8. Creating an Off-Site Backup via E-mailAnother option for the off-site backup of a limited number of files is to use e-mail. In particular, at thetime of this writing, Gmail offered 7GB of storage for free and was prepared to sell you further space; youmay even have access to your own off-site e-mail server. You can set up a Perl script to e-mail a given setof files to your Gmail account and then run it automatically every night with cron.■ Note There are size limitations with this! Most e-mail servers will limit the size of mail message that they areprepared to accept, because very large e-mails are a nuisance and can cause network slowdown. So, this methodis really useful only for small numbers of smallish files. Text files tend to be small, so it may be reasonable toe-mail yourself a backup of your script directories or even of the dump of your wiki as described in recipe 4-3.It’s not a good solution for an entire home directory, however.The Perl modules Net::SMTP, File::Find, Mime::Lite, Archive::Tar, and IO::Zlib are required forthis script. In Debian, the first two of these are a default part of the regular Perl install; install the otherswith the following:sudo apt-get install libmime-lite-perl libarchive-tar-perl libio-zlib-perlAlternatively, you can install them using CPAN (see the appendix for notes on CPAN and Perlmodules):perl -MCPAN -e "install Net::SMTP"perl -MCPAN -e "install File::Find"perl -MCPAN -e "install Mime::Lite"perl -MCPAN -e "install Archive::Tar"The script looks like this:01 #!/usr/bin/perl -w0203 use strict;04 use Archive::Tar;05 use File::Find;110Download at WoweBook.Com

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

Saved successfully!

Ooh no, something went wrong!