Skip to content

Instantly share code, notes, and snippets.

@xymor
Created May 14, 2014 16:10
Show Gist options
  • Save xymor/03fdde919b89edf14d1c to your computer and use it in GitHub Desktop.
Save xymor/03fdde919b89edf14d1c to your computer and use it in GitHub Desktop.
Gihub Backup
#gitback 0.1
#credits: Walter White, Updates: Addy Osmani
#!/usr/bin/env ruby
# dependencies
require "yaml"
require "open-uri"
# your github username
username = "addyosmani"
time = Time.new
# feel free to comment out the option you don't wish to use.
backupDirectory = "/backups/github/#{time.year}.#{time.month}.#{time.day}"
#or simply: backupDirectory = "/backups/github/"
#repositories =
# .map{|r| %Q[#{r[:name]}] }
#FileUtils.mkdir_p #{backupDirectory}
YAML.load(open("http://github.com/api/v2/yaml/repos/show/#{username}"))['repositories'].map{|repository|
puts "discovered repository: #{repository[:name]} ... backing up ..."
#exec
system "git clone git@github.com:#{username}/#{repository[:name]}.git #{backupDirectory}/#{repository[:name]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment