Skip to content

Instantly share code, notes, and snippets.

@tmilewski
Last active January 6, 2019 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmilewski/a42a78ee38691da21d3cd6efe5db473b to your computer and use it in GitHub Desktop.
Save tmilewski/a42a78ee38691da21d3cd6efe5db473b to your computer and use it in GitHub Desktop.
Backup All Repos
#!/usr/bin/env ruby
# > TOKEN=[PERSONAL ACCESS TOKEN] ruby backup.rb
require 'octokit'
directory = './backups'
client = Octokit::Client.new(
access_token: ENV['TOKEN'],
per_page: 200,
auto_paginate: true
)
client.repos.each do |repo|
puts repo.full_name
dest = "#{directory}/#{repo.full_name}"
system "git clone --quiet git@github.com:#{repo.full_name}.git #{dest}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment