#!/bin/sh # # $Id$ # # Sync the snapshot files to the local archive # # Rick van der Zwet FQDN=${1:-tyan.wirelessleiden.nl} HOSTID=`echo $FQDN | awk -F "." '{print $1}'` BACKUP_USER=${BACKUP_USER:-${2:-backup}} SSH_KEY=${3:-/root/.ssh/backup.key} DIRS=${4:-"configbackup mysqlbackup"} EXCLUDES=`dirname $0`/excludes SNAPSHOTROOT="/usr/backup/$HOSTID" # Deleting will be done manually to avoid whipe-outs. OPTS="--force --ignore-errors --archive" if [ -r $EXCLUDES ]; then OPTS="$OPTS --exclude-from=$EXCLUDES" fi for DIR in $DIRS; do TARGET=$SNAPSHOTROOT/$DIR SOURCE=/usr/backup/$HOSTID/$DIR mkdir -p $TARGET # now the actual transfer rsync --rsh="ssh -i $SSH_KEY -l $BACKUP_USER" $OPTS $FQDN:$SOURCE $TARGET done