geordy_backup

Rotating rsync backups.

Download

View geordy_backup

Description

I'm a sloppy person, so I set up a solution derived from a script I snagged through googling. geordy_backup uses rsync to make four-hourly, daily, weekly, and monthly (remote) backups, using not much more than the space to hold one backup, and runs on Linux. It is adapted from a script by Geordy Kitchen that I found on the Web. I have used it on various installations of CentOS 4+5 and Fedora 9+11 for both remote and local backups.

The "sloppyness" principle suggests that I won't know exactly which files to back up, nor will I remember to make the backups. geordy_backup is fully automatic and quickly backs up entire directory hierarchies. I usually back up all of:

  • /home/
  • /root/
  • /var/www/
  • /var/log/
  • /var/spool/mail/
  • /etc/
  • /usr/src/redhat/

Installation

Download the script and edit "dst=/mnt/backups/example.com.d", 'srcroot="root@example.com"', the "src='" section, and possibly the "filter='" section and "monthly=60".

Add appropriate entries to your crontab with the command `crontab -e`, using the examples at the top of the script.

Usage

geordy_backup will run automatically if installed as above. Errors in operation will be mailed to the crontab's owner. Every year or so, it might be reasonable to rotate the log file, geordy_backup.out.

Remote backups will normally need to authenticate the SSH connection. Rather than put a password in the script, it is better to set up key-based authentication. See ssh-keygen and possibly set /etc/ssh/sshd_config on the remote system to allow only key-based login with "PermitRootLogin without-password". For fully automatic operation, make the key passwordless, but run geordy_backup from a secure account.

If there are large frequently-changing files, the backups will use more space. It might be reasonable to exclude some of those files from the backups. This might work best if the files are automatically rotated with logrotate, so that they will eventually be backed up. One might also add a bit of post-rotation code to geordy_backup that removes (some of) the large files from the rotated backups. Personally, I can afford the space and usually don't do anything.

During the initial weeks, you will get warning emails that some of the "--link-dest=" destinations do not exist. I just wait until they stop, but you could remove the offending "--link-dest=" lines and try to remeber to replace them later. They are only needed when something goes wrong with an hourly backup, so there will be alternative places to look.

 

Back to Tony NelsonJHC's R Pentomino's Home Page

Valid HTML 4.0!