Tuesday 19 June 2007

Installing rsync to automate backups onto the NSLU2 Fileserver

Install rsync on the Fileserver -

apt-get install rsync

edit /etc/rsyncd.conf

# rsyncd.conf
uid = share
gid = share
use chroot = yes
max connections = 2
syslog facility = local3
pid file = /var/run/rsyncd.pid
[GiddyKipper]
path = /home/share/backups/GiddyKipper
comment = nslu2 rsync backup of GiddyKipper
read only = no
[SillySausage]
path = /home/share/backups/SillySausage
comment = nslu2 rsync backup of SillySausage
read only = no

Started rsync in daemon mode -

rsync --daemon

Should now be able to see the rsysnc server from another machine on the LAN -

andrew@giddykipper:~$ sudo rsync fileserver::
GiddyKipper nslu2 rsync backup of GiddyKipper
SillySausage nslu2 rsync backup of SillySausage
andrew@giddykipper:~$

Clients 'push' backups onto the server - i.e. to back-up my Linux 'home' directory on GiddyKipper -

rsync -arv --delete /home/andrew/ fileserver::GiddyKipper/andrew/

In order for this backup to run daily, the following script is added to /etc/cron.daily

#!/bin/sh
#
# backup cron daily
rsync -arv --delete /home/andrew/ fileserver::GiddyKipper/andrew/

For Windows machine, need to install cygwin, and then install rsync within cygwin. Backups are run as -

rsync -arv --delete /cygdrive/c/Documents\ and\ Settings/Rachel/ fileserver::SillySausage/Rachel/

and can include explicit exclude options to avoid lots of junk -

--exclude '*/Temporary\ Internet\ Files/*'

To run regular backups, need to add something like the following script to "Scheduled Tasks" to be run as an Administrator -

c:
cd c:\cygwin\bin
bash --login -c "rsync -avr --log-file=/cygdrive/c/backup.log --delete --exclude '*/Temporary\ Internet\ Files/*' /cygdrive/c/Documents\ and\ Settings/Rachel/ fileserver::SillySausage/Rachel/"

2 comments:

Case said...

are you aware of rsnapshot?

andrew said...

Yes, I'd like to try rsnapshot but haven't got round to it yet.

At the moment, all my backup clients 'push' backups onto the server whenever they want to. With rsnapshot I think I'd have to change things round so the server 'pulls' backups from the client at predetermined times. This might cause problems if the clients are not available at the time -e.g. laptops etc. that are only on-line irregularly?