Created
December 8, 2010 17:49
-
-
Save thuss/733623 to your computer and use it in GitHub Desktop.
A simple script to backup github repositories
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
#!/bin/bash -e | |
# | |
# This script clones or fetches the latest updates from selected repo's and then tar's them up | |
# | |
CHECKOUT_DIR=$HOME/backups/checkouts | |
BACKUP_DIR=$HOME/backups/tarballs | |
LOG=/tmp/github-daily-backups.log | |
REPOS="vm-main vm-cdn vm-operations-chef vm-iphone vm-contrib" | |
function clone_or_fetch { | |
cd $CHECKOUT_DIR | |
if [ -d $1 ]; then | |
echo "Fetching $1" >> $LOG | |
cd $1 | |
git fetch origin >> $LOG | |
else | |
echo "Cloning $1" >> $LOG | |
git clone -n [email protected]:volunteermatch/${1}.git >> $LOG | |
fi | |
} | |
# Fetch (update) or clone (checkout) each repo | |
echo `date` : starting $0 >> $LOG | |
for repo in $REPOS | |
do | |
clone_or_fetch $repo | |
done | |
# Create the daily tarball using the day of the month in the filename | |
cd $CHECKOUT_DIR | |
echo Tarring and bzipping backup to $BACKUP_DIR/nightly-for-day-`date +%d`.tbz >> $LOG | |
tar -cjf $BACKUP_DIR/nightly-for-day-`date +%d`.tbz $REPOS >> $LOG | |
echo `date` : finished $0 >> $LOG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment