Skip to content

Instantly share code, notes, and snippets.

@fedir
Forked from nicerobot/backup.sh
Last active April 21, 2024 21:31
Show Gist options
  • Select an option

  • Save fedir/5466075 to your computer and use it in GitHub Desktop.

Select an option

Save fedir/5466075 to your computer and use it in GitHub Desktop.
Clone or update all user's gists #backup #github #gists #management
#!/usr/bin/env python
# Clone o update all a user's gists
# curl -ks https://raw.github.com/gist/1622504/gist-backup.py | python
# curl -ks https://raw.github.com/gist/1622504/gist-backup.py | USER=nicerobot python
import json
import urllib
from subprocess import call
from urllib import urlopen
import os
USER = os.environ['USER']
u = urlopen('https://gist.github.com/api/v1/json/gists/' + USER)
gists = json.load(u)['gists']
startd = os.getcwd()
for gist in gists:
gistd = gist['repo']
if os.path.isdir(gistd):
os.chdir(gistd)
call(['git', 'pull', 'git://gist.github.com/' + gistd + '.git'])
os.chdir(startd)
else:
call(['git', 'clone', 'git://gist.github.com/' + gistd + '.git'])
@ulf1
Copy link
Copy Markdown

ulf1 commented Jun 20, 2016

thank you. works for me.

@JulienMalige
Copy link
Copy Markdown

JulienMalige commented Jul 12, 2017

good job!

@mattmc3
Copy link
Copy Markdown

mattmc3 commented Jul 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment