Linux‎ > ‎

Backups With rsync

ON THE SERVER THAT WANTS TO GET BACKED UP

backup.sh

#!/bin/sh
/usr/local/bin/rsync -av --delete --exclude-from=/exclude-rsync -e ssh /
root@bakupserver.compute.info:/snapshot/isengard > /tmp/backup.log 2>&1

mail -s "Backup for `hostname` `date`" backups@compute.info < /tmp/backup.log

Setup cronjob

crontab -e

enter in cron:

10 4 * * * /usr/local/sbin/backup.sh



ON THE BACKUP SERVER

rotate-snapshots.sh

#!/bin/sh
mv /backups/snapshot.3 /backups/snapshot.tmp
mv /backups/snapshot.2 /backups/snapshot.3
mv /backups/snapshot.1 /backups/snapshot.2
mv /backups/snapshot.0 /backups/snapshot.1
mv /backups/snapshot.tmp /backups/snapshot.0
cp -al /backups/snapshot.1/. /backups/snapshot.0
moria:/root$ crontab -l
0 0 * * * /usr/local/sbin/rotate-snapshots.sh


Comments