备份/镜像Github存储库

5 backup github

我想定期创建我的github存储库的备份.是否有一种快速的方法可以在不知道整个列表是什么的情况下拉出所有这些?

沃尔特

小智 2

我一直在等待的答案。

我决定尝试一下 Ruby,结果还不错。我喜欢它的紧凑性,但它看起来不太漂亮:(。

这有效:

#!/usr/bin/env ruby
require "yaml"
require "open-uri"

time = Time.new
backupDirectory = "/storage/backups/github.com/#{time.year}.#{time.month}.#{time.day}"
username = "walterjwhite"

#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 "found repository: #{repository[:name]} ... downloading ..."
    #exec
    system "git clone git@github.com:#{username}/#{repository[:name]}.git #{backupDirectory}/#{repository[:name]}"
}
Run Code Online (Sandbox Code Playgroud)

沃尔特