Skip to content

Instantly share code, notes, and snippets.

@devshorts
Last active June 15, 2018 21:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devshorts/ff372507110dbdcf465e25bd1bbeb9a8 to your computer and use it in GitHub Desktop.
Save devshorts/ff372507110dbdcf465e25bd1bbeb9a8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'octokit'
require 'pp'
Octokit.auto_paginate = true
org=ARGV[0]
client = Octokit::Client.new(:access_token => "#{ENV['GIT_ACCESS_TOKEN']}")
repos = client.org_repositories(org)
repos.select {|repo| !repo.fork}.each do |repo|
puts "Processing #{repo.name}"
if File.directory?(repo.name) then
puts "Pulling..."
`cd #{repo.name} && git pull`
else
puts "Cloning..."
`mkdir -p #{repo.name}`
`cd #{repo.name}`
`git clone #{repo.clone_url}`
`cd ..`
end
end
@devshorts
Copy link
Author

devshorts commented Dec 15, 2017

./backup.rb <org name>

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