#!/bin/sh # # $Id$ # # Backup WebDAV and Subversion and Wiki # # Rick van der Zwet FQDN=${1:-tyan.wirelessleiden.nl} HOSTID=`echo $FQDN | awk -F "." '{print $1}'` DIRS=${2:-"drupal wiki webfolder svn"} BACKUP_USER=${BACKUP_USER:-${3:-backup}} SSH_KEY=${4:-/root/.ssh/backup.key} EXCLUDES=`dirname $0`/excludes DELETEROOT="/usr/backup/$HOSTID/wwwbackup/old" MIRRORROOT="/usr/backup/$HOSTID/wwwbackup/current" BACKUPDIR=$DELETEROOT/`date '+%Y/%M/%d'` OPTS="--force --ignore-errors --delete-excluded --compress --delete --backup --backup-dir=$BACKUPDIR --archive" if [ -r $EXCLUDES ]; then OPTS="$OPTS --exclude-from=$EXCLUDES" fi for DIR in $DIRS; do TARGET=$MIRRORROOT/$DIR SOURCE=/usr/local/www/$DIR mkdir -p $TARGET $BACKUPDIR # now the actual transfer rsync --rsh="ssh -i $SSH_KEY -l $BACKUP_USER" $OPTS $FQDN:$SOURCE $TARGET done