Datestamped backup of git repositories managed by gitosis

#git

Published: Aug 19, 2011

This is a neat little demonstration of the power of the UNIX pipes.

#!/bin/bash

'''
A script to backup all the git repositories managed by gitosis
and create a date stamped tarball.

Pradeep Gowda
2011-08-19
'''

GITOSISADMIN=$HOME/mycompany/gitosis-admin
GITSERVER="git@gitserver.mycompany.com"
TODAY=`date +%Y-%m-%d`

mkdir gitbackups-$TODAY
grep ^writable $GITOSISADMIN/gitosis.conf | cut -d= -f 2 | tr "\\n" " " | tr " " "\\n"  | sort  | uniq | xargs -I {} git clone $GITSERVER:{}.git gitbackups/{}
tar czf gitbackups-$TODAY.tgz gitbackups

Updates on gist.github.com