Skip to content

Instantly share code, notes, and snippets.

@rduplain
Created July 15, 2012 15:30
Show Gist options
  • Save rduplain/3117464 to your computer and use it in GitHub Desktop.
Save rduplain/3117464 to your computer and use it in GitHub Desktop.
Backup GitHub with dumb scripts.
"A dumb script builder to clone scraped GitHub repo listings."
# 1. Scrape <ul id="repo_listing" class="repo_list"> into listing.html
# 2. python build_clone_script.py | sort -u > clone.sh
# 3. time sh clone.sh
from __future__ import print_function
import lxml.html
data = open('listing.html', 'r')
dom = lxml.html.fromstring(data.read())
for element in dom.cssselect('.source'):
owner = element.cssselect('.owner')[0].text.strip()
repo = element.cssselect('.repo')[0].text.strip()
cmd = 'git clone --mirror git@github.com:{0}/{1}.git {0}-{1}.git'\
.format(owner, repo)
print(cmd)
#!/bin/bash
# Updates all mirrored .git directories in the current directory.
for repo in *.git; do
pushd $repo
git fetch
popd > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment