I wanted a solution with the following features:
- centralized management of directories to backup and schedule.
- automated backup
- minimal software on the windows PC
- open source
What I did:
Installed Deltacopy on the windows PC's. This is basically a rsync server with a GUI. I created one big "rsync-share" which is the C: drive.
On the linux fileserver (a nslu2 with a big usb disk) I wrote some small scripts.
Here is an example:
#!/bin/bash
BCKHOST=mylaptop
HOSTUSER=backup
HOSTPASSFILE=/root/backup/passw/$BCKHOST
RSYNCPARMS="-avtol --stats --bwlimit=200 --delete"
DESTDIR=/home/share/deltacopy
SRCDIR1=/c_drive/DOCS
BCKLOG=/var/log/deltacopy/$BCKHOST.log
chmod 600 $HOSTPASSFILE
while test 1
do
while ! ping -c1 -w4 $BCKHOST > /dev/null
do
sleep 300
done
echo "DELTACOPY -- [`date`] $BCKHOST is up" >> $BCKLOG
sleep 200
echo "DELTACOPY -- [`date`] starting backup on $BCKHOST" >> $BCKLOG
rsync $RSYNCPARMS --password-file=$HOSTPASSFILE rsync://$HOSTUSER@$BCKHOST$SRCDIR1 $DESTDIR/$BCKHOST 1>> $BCKLOG 2>> $BCKLOG
echo "DELTACOPY -- [`date`] backup finished" >> $BCKLOG
while ping -c1 -w5 $BCKHOST > /dev/null
do
sleep 300
done
echo "DELTACOPY -- [`date`] $BCKHOST is down" >> $BCKLOG
done
For each host you'll have to make a copy of this script.
The script waits until the PC is on the network and then starts the rsync backup. When finished it waits until it's powered off. Then the scripts starts over again. At night a second script takes care of email notification, here it is:
#!/bin/bash
# usage: sendreport
REPORT=/var/log/deltacopy/$1.log
RECIPIENT=$2
DATESTAMP=`date | cut -b 1-10`
if [ ! -f $REPORT ]; then
SUBJECT="[$HOSTNAME] - MISSING backup for $1 on $DATESTAMP"
else
if ( `grep -q "rsync" $REPORT` || `grep -q "fail" $REPORT`); then
SUBJECT="[$HOSTNAME] - FAILED backup for $1 on $DATESTAMP"
else SUBJECT="[$HOSTNAME] - SUCCESSFUL backup for $1 on $DATESTAMP"
fi
fi
cat $REPORT | mail -s"$SUBJECT" $RECIPIENT
Et voila... simple and reliable.
Feel free to comment.