#!/bin/sh -ex # # will browse through a list of repositories (at ~/etc/bzr-backup-repos) # REPO_LIST=~/etc/bzr-backup-repos LOCATIONS_LIST=~/etc/bzr-backup-locations BACKUP_LOCATIONS= SSH_KEY=~/etc/bzr-backup.id_dsa check_branches() { local REPO=$1 for path in `find $REPO -name .bzr`; do # skip shared repositories: test "$path" = "$REPO/.bzr" && continue repopath=`dirname $path` bzr check $repopath if [ $? -ne 0 ]; then echo "bzr check failed for $path, stopping the "\ "backup process." >&2 exit 1 fi done } rsync_repo() { local REPO=$1 for location in `cat $LOCATIONS_LIST | grep -v '^#'`; do if rsync -rz -e "ssh -i $SSH_KEY" $REPO $location; then echo "backup to $location OK" else echo "WARNING: backup to $location FAILED" >&2 fi done } sync_shared_repo() { local REPO=$1 check_branches $1 rsync_repo $1 } main() { for path in `cat $REPO_LIST | grep -v '^#'`; do sync_shared_repo $path done } main