I have some repositories on github, and I don't really want to lose my code if they go titsup, or if someone files a DMCA complaint and github rm -rf /jgaa!
So I decided to back up my data. I duckducked a bit for a solution, and - well there were some answers, but they were way to complex. git is a simple thing. So it should be simple to use it to back itself up, right?
Well, it is.
1) I created a local backup directory for it
$ mkdir /var/backup/github
2) I asked git to mirror my repositories.
$ git clone --mirror https://github.com/jgaa/doc.git /var/backup/github/doc.git
$ git clone --mirror https://github.com/jgaa/restc-cpp.git /var/backup/github/restc-cpp.git
3) I wrote a simple bash script to pull changes for the repositories
The script looks like this:
for f in $BASE/*.git; do
echo "Going to $f"
git remote update
4) I called the backup script from a cron file in /etc/cron.d to pull the changes every night
0 1 * * * jgaa /usr/local/bin/backup-git