Created
November 16, 2014 17:18
-
-
Save cato-/f0d2cda0070911da1887 to your computer and use it in GitHub Desktop.
Backup all public repositories of specified user, designed to run from daily cron
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 | |
USER=$1 | |
if [ -n "$2" ]; then | |
VERBOSE=echo | |
else | |
VERBOSE=: | |
fi | |
umask 0027 | |
cd $(dirname $0) | |
curl -s https://api.github.com/users/${USER}/repos?type=owner | grep git_url | sed 's,^.* ",,; s/",$//;' | while read l; do | |
if [ ! -e $(basename $l) ]; then | |
$VERBOSE "Initial Backup of $l" | |
git clone --quiet --mirror $l; | |
echo "section=GitHub Backup" > $(basename $l)/cgitrc | |
echo "Backup of $l" > $(basename $l)/description | |
fi; | |
done | |
for d in *.git; do | |
$VERBOSE "Update of $d" | |
git --git-dir $d remote update > /dev/null; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment