How To Copy An Entire Amazon S3 Bucket

1. You need Ruby, rubygems and the right_aws gem.
yum install ruby rubygems
gem update –system
gem install right_aws
2. Replace any values inside curly braces {} below with real values and remove the curly braces. YMMV
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
require 'rubygems' require 'right_aws' S3ID = "{S3 ID GOES HERE}" S3KEY = "{S3 KEY GOES HERE}" SRCBUCKET = "{your-s3-bucket-1}" DESTBUCKET = "{your-s3-bucket-2}" 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.') |
Leave Your Comment
All fields marked with "*" are required.