Skip to content

Instantly share code, notes, and snippets.

@cnlpete
Created May 16, 2011 15:18
Show Gist options
  • Save cnlpete/974629 to your computer and use it in GitHub Desktop.
Save cnlpete/974629 to your computer and use it in GitHub Desktop.
really basic script to backup a ouple of git-repos , for instance to put in cron or rsnapshot or similar
#!/bin/bash
##host
githost="git@mitharas.de"
#----------
# get list of repos using git gl-info from https://cnlpete@github.com/cnlpete/gitolite-tools.git
#install git ls-info
curdir=`pwd`
cd /tmp
#git clone https://cnlpete@github.com/cnlpete/gitolite-tools.git gitolite-tools
#cd gitolite-tools
#make && sudo make install
cd $curdir
repos=`git gl-info ${githost} | awk '/.*R.*\w+/ {print $NF}' | tr -d '\r'`
for line in ${repos}
do
echo ${line}
if [ ! -d ${line}.git ]; then
mkdir ${line}.git
git clone --mirror -q ${githost}:${line} ${line}.git > /dev/null
fi
cd ${line}.git
git remote update > /dev/null
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment