Pages

Thursday, February 18, 2016

Best way to move files between S3 buckets - Different S3 Accounts

Here is a ruby class for performing this: https://gist.github.com/4080793

$ gem install aws-sdk
$ irb -r ./bucket_sync_service.rb
> from_creds = {aws_access_key_id:"XXX",
                aws_secret_access_key:"YYY",
                bucket:"first-bucket"}
> to_creds = {aws_access_key_id:"ZZZ",
              aws_secret_access_key:"AAA",
              bucket:"first-bucket"}
> syncer = BucketSyncService.new(from_creds, to_creds)
> syncer.debug = true # log each object
> syncer.perform
This will copy complete bucket content to new bucket.

2 comments:

  1. Nikhil, good work, please add it to askrubyexpert.com also.

    ReplyDelete
  2. Nikhil, good work, please add it to askrubyexpert.com also.

    ReplyDelete