Last active
September 27, 2015 00:58
-
-
Save joshnuss/1186957 to your computer and use it in GitHub Desktop.
Copy S3 bucket
This file contains 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
require 'right_aws' | |
old_name = "old-bucket" | |
new_name = "new-bucket" | |
s3 = RightAws::S3.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']) | |
old_bucket = s3.bucket(old_name) | |
new_bucket = s3.bucket(new_name) | |
old_bucket.keys.each do |old_key| | |
puts "Copying #{old_key.name} to #{new_bucket.name}" | |
new_key = RightAws::S3::Key.create(new_bucket, old_key.name) | |
old_key.copy(new_key) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment