| #!/bin/sh |
| # |
| # a basic backup script for the stuff on the zone; we can't check it all |
| # in due to (a) volume and (b) embedded rsync passwords in .corpus files etc. |
| # |
| # run as root, a la |
| # |
| # sudo /export/home/svn-trunk/backend/root/backup/backup_zone |
| |
| bupdir=/zonestorage/spamassassin/backup |
| [ `uname -n` = spamassassin2 ] && bupdir=/zonestorage/spamassassin2/backup |
| |
| ########################################################################### |
| |
| die () { |
| echo "$*" 1>&2 |
| exit 1 |
| } |
| |
| rsyncup () { |
| dir="$1" |
| name=$2 |
| |
| rsync=rsync |
| [ -x /usr/sfw/bin/rsync ] && rsync=/usr/sfw/bin/rsync |
| [ -x /opt/sfw/bin/rsync ] && rsync=/opt/sfw/bin/rsync |
| [ -x /opt/csw/bin/rsync ] && rsync=/opt/csw/bin/rsync |
| |
| excludedir=`dirname $0` |
| |
| [ -d rsynced/$name ] || mkdir -p rsynced/$name |
| chmod 700 rsynced |
| |
| touch $name.log |
| chmod 600 $name.log |
| |
| ( |
| #nice -20 $dtar --create --file=- \ |
| #--sparse --exclude-from=$excludedir/excludes \ |
| #--label="Backup of $dir at `date`" \ |
| #"$dir" | nice -20 gzip -2 |
| |
| nice -20 $rsync -a \ |
| --hard-links --whole-file --delete \ |
| --sparse --exclude-from=$excludedir/excludes \ |
| "$dir/." "rsynced/$name/." |
| |
| ) > $name.log 2>&1 |
| } |
| |
| ########################################################################### |
| |
| mkdir -p $bupdir 2>/dev/null |
| cd $bupdir || die "failed to cd to $bupdir" |
| |
| [ -f LOG ] && mv LOG LOG.1 |
| [ -f LOG.1 ] && mv LOG.1 LOG.2 |
| |
| ( |
| for dir in `ls /export/home` ; do |
| |
| [ "$dir" = "OBSOLETE" ] && continue |
| rsyncup /export/home/$dir export-home-$dir |
| |
| done |
| |
| rsyncup /usr/local usr-local |
| rsyncup /var/www var-www |
| rsyncup /opt opt |
| rsyncup /local local |
| rsyncup /etc etc |
| |
| ) 2>&1 | tee LOG |
| |
| exit 0 |
| |