Created
February 17, 2010 17:49
-
-
Save dmdeller/306850 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# config | |
date=`date "+%Y-%m-%d"` | |
git_binary=/usr/local/bin/git | |
# repositories in /git, space-separated. | |
repos="foo.git bar.git" | |
# back up repositories | |
cd /git | |
for repo in $repos | |
do | |
tar -czf /git/backup/${repo}-${date}.tar.gz ${repo} | |
done | |
# garbage-collect; reclaim disk space and optimize for performance | |
# | |
# NOTE: there is a GOOD REASON we do this AFTER backing up: | |
# if you accidentally deleted a branch or something, there might still be traces of it left before garbage-collecting. | |
# after running 'git gc', those traces are gone forever. | |
for repo in $repos | |
do | |
cd /git/${repo} && $git_binary gc --quiet | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment