Index
Documents
Publications
ETH
Diving
Software
Pictures
Server info
Blog

Search

Matteo Corti — Backup with rsync

Script to incrementally back up a machine with rsync (adapted from http://samba.anu.edu.au/rsync/examples.html ):

#!/bin/sh

# directories to backup
DIR="/root \
/etc \
/home \
/usr/local/HotSaNIC/ \
/var/lib/imap \
/var/lib/mailman \
/var/lib/mysql \
/var/log \
/var/spool/imap \
/var/www"


# the name of the backup machine
BSERVER=[omitted]
BUSER=[omitted]
BDIR=/backup/matteocorti.ch 

########################################################################

BACKUPDIR=`date +%A`

OPTS="-e ssh --force --ignore-errors --delete --backup \
  --backup-dir=$BDIR/$BACKUPDIR -a -z --partial --relative --size-only"
      
# the following line clears the last weeks incremental directory
[ -d $HOME/emptydir ] || mkdir $HOME/emptydir
rsync --delete -a $HOME/emptydir/ $BUSER@$BSERVER:$BDIR/$BACKUPDIR/
rmdir $HOME/emptydir
      
# now the actual transfer
rsync $OPTS $DIR $BUSER@$BSERVER:$BDIR/current
	    

Valid HTML 4.01! Valid CSS! www.cacert.org Bone Marrow Donors Worldwide