File:  [Local Repository] / sludge_scripts / backup.sh
Revision 1.1: download - view: text, annotated - select for diffs
Tue Jun 7 12:34:47 2011 UTC (13 years, 4 months ago) by nick
Branches: MAIN
CVS tags: HEAD
Initial revision

#!/bin/bash

REMOTE="nick@demandred.dyndns.org"
OPTIONS="-avxz -e ssh --delete"
LOGDIR=/home/backup/logs
DATE=`date +%Y%m%d`

DIRS=( /home/nick/database-backup.dump.gz /home/nick/database-backup.dump.yesterday.gz /home/nick/DroidBackups /home/winshare/Pictures /home/cvs /home/nick/bbs /home/nick/notes /home/httpd /home/nick/Documents /home/nick/mail /home/nick/mail-backup /home/winshare/Documents )

LANFEAR_DIRS=(/home/backup/systems/lanfear/home/nick/Documents /home/backup/systems/lanfear/home/nick/Receipts "/home/backup/systems/lanfear/home/nick/Nick\'s Pictures" /home/backup/systems/lanfear/home/nick/projects /home/backup/systems/lanfear/home/nick/notes)

[ -d $LOGDIR ] || mkdir -p $LOGDIR

cd /home/backup/backups
mkdir -p demandred
cd demandred
for DIR in "${DIRS[@]}"; do
	/usr/bin/rsync $OPTIONS $REMOTE:$DIR . >> $LOGDIR/backup-$DATE.log 2>&1
done
cd -

mkdir -p lanfear
cd lanfear
for DIR in "${LANFEAR_DIRS[@]}"; do
	/usr/bin/rsync $OPTIONS $REMOTE:$DIR . >> $LOGDIR/backup-$DATE.log 2>&1
done
cd -

##
## Compress logs after 5 days and delete logs after 6 months
##
find $LOGDIR -type f -name \*.gz -mtime +180 -exec rm -f {} \;
find $LOGDIR -type f -name \*.log -mtime +5 -exec gzip -9 {} \;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>