How to copy an object from one S3 bucket to another using s3cmd?

To copy an object from one S3 bucket to another using s3cmd, you can follow these steps:

  1. Install and set up s3cmd on your machine if you haven't already. You can download it from the s3cmd website and configure it by running s3cmd --configure and providing your AWS Access Key ID, Secret Access Key, and other required details.

  2. Use the s3cmd cp command to copy the object. The basic syntax for the command is: s3cmd cp s3://source-bucket/path/to/source-object s3://destination-bucket/path/to/destination-object

    Replace source-bucket with the name of the source bucket, path/to/source-object with the path of the source object (if applicable), destination-bucket with the name of the destination bucket, and path/to/destination-object with the path where you want the object to be copied in the destination bucket (if applicable). You can also specify a specific object name in the destination bucket instead of using the original name.

    For example, to copy an object named example.txt from bucket1 to bucket2, you would run: s3cmd cp s3://bucket1/example.txt s3://bucket2/

    If you want to preserve the metadata and ACLs of the source object during the copy, you can use the --preserve option as well: s3cmd cp --preserve s3://source-bucket/path/to/source-object s3://destination-bucket/path/to/destination-object

  3. Wait for the copy operation to complete. Once the copy is finished, you will see the output indicating the successful completion of the command.

That's it! The object should now be copied from the source bucket to the destination bucket using s3cmd.