Skip to content

Instantly share code, notes, and snippets.

@bdotdub
Created March 27, 2009 22:05
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 bdotdub/86931 to your computer and use it in GitHub Desktop.
Save bdotdub/86931 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'aws/s3'
class GitRepoArchiver
attr_reader :repo_name, :repo_dir, :bucket
def init(args)
# Change the current working directory
end
def archive
self.pull_repo
self.make_archive
self.put_archive
end
def pull_repo
command = "git pull master"
system command
end
def make_archive
command = "tar cfvz #{@repo_name}.tgz #{@repo_dir}"
end
# Here, we take the tarball that was created and push it into the bucket
def put_archive
# Construct the key
now = Time.now
ymd = now.strftime("%Y%m%d")
hms = now.strftime("%H%M%S")
key = "/#{ymd}/#{hms}.#{@filename}"
# Throw it up!
AWS::S3::S3Object @filename, open("#{@path}/#{@filename}"), @bucket
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment