3 # This script does personal backups to a rsync backup server. You will end up
4 # with a 7 day rotating incremental backup. The incrementals will go
5 # into subdirectories named after the day of the week, and the current
6 # full backup goes into a directory called "current"
8 if [ $(id -u) != 0 ] ; then
9 echo "You must be root to run this, please enter passwd"
14 BDIR="/var/lib/gforge/chroot /var/lib/mailman /etc"
15 PATTERNS="mailman postgresql exim4 gforge"
17 DEST="/var/lib/gforge/backup"
19 # BACKUPDIR=`date --date yesterday +%A`
21 # BACKUPDIR=`date --date tomorrow +%A`
22 # BACKUPDIR=`date --date "2 days" +%A`
23 OPTS="--force --ignore-errors --delete --backup --backup-dir=$DEST/$BACKUPDIR -a"
25 [ ! -d ${DEST} ] && mkdir ${DEST}
26 [ ! -d ${DEST}/postgres ] && mkdir ${DEST}/postgres
27 [ ! -d ${DEST}/debconf ] && mkdir ${DEST}/debconf
29 echo "Backuping data from $BDIR"
30 # the following line clears the last weeks incremental directory
31 [ -d $DEST/emptydir ] || mkdir $DEST/emptydir
32 rsync --delete -a $DEST/emptydir/ $DEST/$BACKUPDIR/
35 # now the actual transfer
36 rsync $OPTS $BDIR $DEST/current
38 export FUSIONFORGE_NO_PLUGINS=true
39 COMPRESSOR=$(/usr/share/gforge/bin/forge_get_compressor)
40 EXTENSION=$(/usr/share/gforge/bin/forge_get_compressed_extension)
42 echo "Dumping database"
43 su -s /bin/bash postgres -c "pg_dump -F c -d gforge" | $COMPRESSOR > ${DEST}/postgres/gforge.dump${EXTENSION}
45 echo "Dumping debconf keys"
48 debconf-copydb configdb stdout -c Name:stdout -c Driver:Pipe -c InFd:none \
49 --pattern='^'${PAT}'/' > ${DEST}/debconf/${PAT}.txt
50 chmod 0700 ${DEST}/debconf/${PAT}.txt