rlib/aws_connection.rb
# Copy one bucket to another, skipping content already in the destination bucket.
# @param src_bucket [String] If null, then the current bucket is used
# @param dest_bucket [String] bucket to rsync source bucket objects to.
Copy one bucket to another, skipping content already in the destination bucket.
Copy one bucket to another skipping content already in the destination bucket .
def rsync(dest_bucket:, src_bucket: nil)
    src_bucket ||= @bucket
    dest_dir_list = {}
    bucket_ls(bucket: dest_bucket) { |o| dest_dir_list[o.key] = o.etag }
    count = size = 0
    bucket_ls(bucket: src_bucket) do |object|
      if dest_dir_list[object.key].nil? || dest_dir_list[object.key] != object.etag
        print "#{object.key}\r"
        object_copy(src_bucket: src_bucket, src_key: object.key, dest_bucket: dest_bucket, dest_key: object.key)
        size += object.size
        count += 1
      end
    end
    puts "\nCopied: #{count} files, Total #{size / (1024.0 * 1024.0 * 1024.0)}GiB"
  end
def rsync ( dest_bucket : , src_bucket : nil ) src_bucket ||= @bucket dest_dir_list = { } bucket_ls ( bucket : dest_bucket ) { | o | dest_dir_list [ o . key ] = o . etag } count = size = 0 bucket_ls ( bucket : src_bucket ) do | object | if dest_dir_list [ object . key ] . nil? || dest_dir_list [ object . key ] != object . etag print "#{object.key}\r" object_copy ( src_bucket : src_bucket , src_key : object . key , dest_bucket : dest_bucket , dest_key : object . key ) size += object . size count += 1 end end puts "\nCopied: #{count} files, Total #{size / (1024.0 * 1024.0 * 1024.0)}GiB" end
Copy one bucket to another, skipping content already in the destination bucket.
Copy one bucket to another skipping content already in the destination bucket .
dest_bucket
bucket to rsync source bucket objects to.
bucket to rsync source bucket objects to .
src_bucket
If null, then the current bucket is used
If null then the current bucket is used