Skip to content

Instantly share code, notes, and snippets.

@realeroberto
Created April 20, 2017 15:38
Show Gist options
  • Save realeroberto/9d790d2ba72f9a6e9695c5556fba0835 to your computer and use it in GitHub Desktop.
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.
#!/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