Last active
February 27, 2016 15:18
-
-
Save W4RH4WK/ca4b5f233afa77802757 to your computer and use it in GitHub Desktop.
Github Backup
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
#!/usr/bin/env python | |
import requests | |
token = 'INSERT TOKEN HERE' | |
def list_repos(): | |
repos = requests.get( | |
'https://api.github.com/user/repos?per_page=1000', | |
headers={'Authorization': 'token ' + token} | |
).json() | |
for r in repos: | |
print r['clone_url'] | |
def list_gists(): | |
gists = requests.get( | |
'https://api.github.com/gists?per_page=1000', | |
headers={'Authorization': 'token ' + token} | |
).json() | |
for g in gists: | |
print g['git_pull_url'] | |
if __name__ == '__main__': | |
list_repos() | |
list_gists() |
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 | |
GITHUB_REPOS="$HOME/bin/github_repos" | |
BACKUP_DIR="$HOME/archive/github" | |
for repo_url in $($GITHUB_REPOS); do | |
repo_dir="${repo_url##*/}" | |
if [[ -d "$BACKUP_DIR/$repo_dir" ]]; then | |
git --git-dir "$BACKUP_DIR/$repo_dir" remote update | |
else | |
git clone --mirror "$repo_url" "$BACKUP_DIR/$repo_dir" | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment