Scheduled Backups With Rsyncbackup On Debian Etch
Author: Oliver Meyer <o [dot] meyer [at] projektfarm [dot] de>
Last edited 03/26/2008
This document describes how to set up and configure rsyncbackup on Debian Etch. Rsyncbackup is a Perl script that cooperates with rsync. It's easy to configure and able to create scheduled backups (partial and incremental backups).
This howto is a practical guide without any warranty - it doesn't cover the theoretical backgrounds. There are many ways to set up such a system - this is the way I chose.
1 Preliminary Note
I used two standard Debian systems for this howto. The first system is the main server (192.168.0.101), the second system is the backup server (192.168.0.102) where the backups will be stored.
2 Needed Packages
2.1 Main Server
apt-get install openssh-client openssh-server rsync unzip
2.2 Backup Server
apt-get install openssh-client openssh-server rsync
3 SSH Keyfiles
Now let's generate SSH keyfiles that we'll later use in conjunction with rsyncbackup to authenticate against the backup server. Please note that it's also possible to generate the keyfiles with the rsyncbackup script (rsyncbackup -r) - I chose this way.
3.1 Backup Server
Create the keyfiles - hit enter if you're asked to enter a passphrase.
ssh-keygen -b 4096 -t rsa -C "Backup Key Comment"
The output should look like this:
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
23:e5:b2:2e:86:2f:e9:bc:76:56:83:6a:8d:f0:d6:23 Backup Key Comment
Now we have to add the public key to the list of authorized keys.
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
After that we copy the private key to the main server.
scp /root/.ssh/id_rsa email@example.com:/root/.ssh/
As a last resort we create folders for the backups.
mkdir -p /backups/configs/
mkdir /backups/logs/ /backups/manual/
3.2 Main Server
Now let's test if all went well. You should be able to log in to the backup server via:
ssh -i /root/.ssh/id_rsa firstname.lastname@example.org
Afterwards log out.
4 Rsyncbackup On The Main Server
4.1 Get It
unzip -d rsyncbackup rsyncbackup.zip
4.2 Script & Configuration Files
Now we have to copy the rsyncbackup script to the right place ...
cp /tmp/rsyncbackup/rsyncbackup/rsyncbackup /usr/local/bin/
chmod 700 /usr/local/bin/rsyncbackup
... before we create the configuration files.
touch /etc/rsyncbackup/config.conf /etc/rsyncbackup/destinations.conf \
ln -s /var/log/rsyncbackup/ /etc/rsyncbackup/logs