Last active
June 15, 2018 21:07
-
-
Save devshorts/ff372507110dbdcf465e25bd1bbeb9a8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./backup.rb <org name>