Created
April 20, 2017 15:38
-
-
Save realeroberto/9d790d2ba72f9a6e9695c5556fba0835 to your computer and use it in GitHub Desktop.
Poor-man Bash hack to backup all of a user's GitHub repositories.
This file contains hidden or 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/sh | |
username= | |
curl -s https://api.github.com/users/$username/repos | jq -r '.[].git_url' | while read git_url | |
do | |
repo_name=$(basename $git_url .git) | |
echo Backing up $repo_name | |
git clone -q $git_url 2> /dev/null || ( | |
cd $repo_name | |
git pull -q | |
) | |
tar cfz ${repo_name}-$(date +%Y%m%d).tar.gz $repo_name | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment