Skip to content

Copy a bucket to another account

View as Markdown

Move a bucket’s contents to another E2E account by copying every object across with an S3-compatible tool: the bucket itself stays where it is, but the data does not have to. This uses mc; see Connect with the mc client for installing it.

In the destination account, create a bucket to receive the data. On both the source and destination bucket, attach an access key with the Bucket Admin role; see Generate an access key.

mc alias set <source-alias> https://objectstore.e2enetworks.net <source-access-key> <source-secret-key>
mc alias set <destination-alias> https://objectstore.e2enetworks.net <destination-access-key> <destination-secret-key>

Use the Chennai endpoint from S3 compatibility instead for a bucket in that region.

mc cp --recursive <source-alias>/<source-bucket> <destination-alias>/<destination-bucket>

--recursive copies every object, including anything under a folder-like prefix. mc shows a progress bar while it copies, and your prompt comes back when it is done.

Count the objects on each side. Each command prints a single number. When the copy is complete, the two match:

mc ls --recursive <source-alias>/<source-bucket> | wc -l
mc ls --recursive <destination-alias>/<destination-bucket> | wc -l

Do not delete anything from the source bucket until the numbers match; on a bucket without versioning, a deleted object cannot be brought back. See Delete a bucket if you no longer need the source bucket at all.