Sha256: 598d980acc0c2e2876c2cc5794a8290f61df2a8bec484d61882be02093ae5375

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

#!/usr/bin/env ruby
# Backs up a GitHub organization's repositories and
# all their associated information for archival purposes.
# Usage: ruby archive.rb

require './lib/github_records_archiver'
require 'parallel'

def logger
  @logger ||= Logger.new(STDOUT)
end

def log(msg)
  logger.info(msg)
end

def error(msg)
  logger.error(msg)
end

archiver = GitHubRecordsArchiver
pwd      = Dir.pwd
start    = Time.now
org_name = ARGV[0] || ENV['GITHUB_ORGANIZATION']
org      = archiver::Organization.new org_name

log "Starting archive for @#{org.name} in #{org.archive_dir}"

log "Found #{org.teams.count} teams"
Parallel.each(org.teams, progress: 'Archiving teams', &:archive)

log "Found #{org.repos.count} repos"
Parallel.each(org.repos, progress: 'Archiving repos') do |repo|
  begin
    repo.clone
    repo.wiki.clone if repo.has_wiki?
    Parallel.each(repo.issues, &:archive)
  rescue GitHubRecordsArchiver::GitError => e
    error "Failed to archive #{repo.name}"
    error e.message
  end
end

Dir.chdir pwd
log "Done in #{Time.now - start} seconds."

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github_records_archiver-0.1.0 bin/archive