#!/bin/bash # # Backup git DB's to sporian. This is an alternate facility to SVN, for # the paranoid like me. Also allows me to keep temp branches. # Ensure we have an ssh key on SVHOST SVHOST=iweb.sporian.com SVDIR=TMI/git SVURL=$SVHOST:$SVDIR rsync_proj() { proj=$1 echo "Project $proj [via rsync]" ( # SVHOST may not have git ssh $SVHOST mkdir -p $SVDIR/${proj}.git rsync -avz --delete $proj/.git/ $SVURL/${proj}.git/ ) } git_proj() { proj=$1 echo "Project $proj [via git]" ( # Easier when SVHOST has git cd $proj ssh $SVHOST test -d $SVDIR/${proj}.git || \ ssh $SVHOST git --git-dir $SVDIR/${proj}.git init --bare --shared=true git push --mirror "$SVURL/${proj}.git" ) } #cd ~/workspace/sporian if [ -n "$1" ]; then if [ -d "$1" -a -d "$1/.git" ]; then #rsync_proj $1 git_proj $1 else echo "$0: skip ~/workspace/sporian/$1; not a git project" >&2 exit 1 fi else for i in $(find . -name .git -type d 2>/dev/null); do #rsync_proj $(basename $(dirname $i)) git_proj $(basename $(dirname $i)) done fi exit 0