Created
May 14, 2014 16:10
-
-
Save xymor/03fdde919b89edf14d1c to your computer and use it in GitHub Desktop.
Gihub 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
#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