Backup using rdiff-backup


I’ve been using rdiff-backup to automate my linux backups for a while now. I just recently made some improvements to my cronjob which performs a nightly backup and thought I’d share it here.

Rdiff-backup is a great application which wraps around rdiff to backup entire directories from one place to another. It’s very efficient too. Rdiff only transfers the changes to files, which means it’s great for performing offsite backups.

Only problem is that it’s still not easy enough to use – so I wrote a script to *really* automate things.

Here’s how to get it working:

  1. Install rdiff-backup on local and remote computers (apt-get install rdiff-backup for debian/ubuntu, build for windows, build for osx or build from source for anything else).
  2. Copy this script to /etc/cron.d/backup (you’ll probably have to rename that downloaded file)
  3. Create configuration directories /etc/backup/ and /etc/backup/hosts/
  4. Create the main configuration file /etc/backup/backup.conf with your settings using this template
    [sourcecode language=’sh’]
    # This is the config for a script which uses rdiff-backup to perform a nightly
    # backup of various
    # servers to this computer. It should be called via cron and should be
    # configured to send stderr to a sysadmin.
    #

    #==============================Config section==================================

    # local directory to store backups
    BACKUP_DIR=/usr/data/backups

    # location of remote host specific back up details
    HOST_CONFIGS_DIR=/etc/backup/hosts

    # Number of days to keep backups for. If unset backups will be kept forever
    KEEP_BACKUP_DAYS=62

    # parameters to pass to rdiff-backup
    RDIFF_BACKUP_PARAMETERS=”–force”

    # set to 0 for debugging information to be suppressed
    DEBUG=1

    #================================End Config Section============================
    [/sourcecode]

  5. Create a configuration file for each host you want to backup. This must be in the format of “backup.hostname” – i.e. backup.hammer.cs.curtin.edu.au or backup beans.ath.cx. You can refer to the localhost through its name too (i.e. backup.mycomp). These must be placed in /etc/backup/hosts/
    [sourcecode language=’sh’]
    # Config options for backing up remote computers
    # filename must be in the format of
    # backup.hostname.domain

    # The directory to start the backup at.
    START_DIR=”/”

    # Directories to backup. use a space to seperate.
    # INCLUDE_DIRS will have preference.
    # ie. if we include /usr/data/wilson but exclude /usr/data everything under
    # /usr/data/wilson will be backed up, but /usr/data/tim won’t be.
    INCLUDE_DIRS=”/usr/data/wilson/data”

    EXCLUDE_DIRS=”/usr/data /proc /cdrom /tmp /mnt /sys /home/squid /home/www/gallery2″
    [/sourcecode]

  6. Create an SSH key with no passphrase which will allow you to logon to the remote computer without typing a password (we will be automating this with cron remember). This link gives some details.
  7. Create a cronjob to run the script.
    30 4 * * *     root    /etc/cron.d/backups

Your remote computers should now be automatically backed up every night!

I haven’t actually tried this with windows or Mac OSX computers, but I believe it can be made to work.

, , , ,

  1. #1 by Rob on May 13, 2009 - 6:20 pm

    Yay your blog is back up and running (I couldn’t access it for a while!?). This is pretty cool.

    What I want to do is to setup some sort of NAS that runs on linux, to use as a backup drive / general network/share drive / web/svn server. That way I can have it on 24/7 and I don’t have to boot up my computer (and leave it running, using 400+W of power) to access svn during the day. If I did, this sort of thing would be perfect for backing up files, in combination with that.

  2. #2 by wilson on August 12, 2009 - 10:39 am

    I somehow missed all these comments!

    We had some “server issues” when I moved. It seems the mains power in our place is a little dodgy and drops down to <210V when people turn kettles/ovens etc on.

    It was causing grief for my server. The undervoltage condition made the server turn itself off, which reduced the load making voltage go up, which made it turn itself on, which raised the load and lowered the voltage.... etc. etc. Poor thing.

    That said, it was probably a little bit of an overkill for a home server... A Dell PowerEdge 2500 with 3x300W power supplies and 12 hard drives in various RAID configurations... It was sitting next to our dining table and felt/sounded a lot like I imagine the jet stream from an Airbus A380 would.

    But that is now gone (well, actually, it's still sitting there as it's too heavy to move). It has been replaced by a PowerEdge SC430 with only three hard drives!

    Which is where I was trying to get to with these ramblings... This server only draws a bit over 100W when idle (most of the time). I wonder how this compares to a dedicated NAS unit?

(will not be published)