Skip to content

Instantly share code, notes, and snippets.

@boj
Created September 10, 2012 07:10
Show Gist options
  • Save boj/3689365 to your computer and use it in GitHub Desktop.
Save boj/3689365 to your computer and use it in GitHub Desktop.
AWS Bucket Copy
#!/usr/bin/env ruby
# From: http://www.austinriba.com/2011/02/copy-contents-of-one-s3-bucket-to-another/
require 'right_aws'
S3ID = "Your AWS ID Here"
S3KEY = "Your AWS secret key"
SRCBUCKET = "Source Bucket"
DESTBUCKET = "Destination Bucket"
s3 = RightAws::S3Interface.new(S3ID, S3KEY)
s3.incrementally_list_bucket(SRCBUCKET) do |h|
h[:contents].each do |o|
puts("Copying " + o[:key])
s3.copy(SRCBUCKET, o[:key], DESTBUCKET, o[:key])
end
end
puts("Done.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment