Amazon Web Services (AWS) - Copy files between S3 Buckets using AWS CLI

by
Jeremy Canfield |
Updated: March 23 2024
| Amazon Web Services (AWS) articles
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
An S3 Bucket is similar to an NFS share in that it is a mountable storage volume.
The aws s3api list-buckets command can be used to list your S3 buckets.
~]$ aws s3api list-buckets
{
"Buckets": [
{
"Name": "my-bucket-abcdefg",
"CreationDate": "2023-06-02T02:22:19+00:00"
}
],
"Owner": {
"DisplayName": "john.doe",
"ID": "ab0e0a411234d5103a77c82240d5abcdc41ff11cc325c65b5c777a5123443743"
}
}
The following commands can be used to upload or download files to an S3 Bucket.
- aws s3api put-object = upload files
- aws s3api copy-object = copy a file in bucket "a" to bucket "b" (this article)
- aws s3api get-object = download files
The aws s3api copy-object command can be used to copy a file in bucket "a" to bucket "b". In this example, foo.txt in bucket1 will be copied to my-bucket-abdefg.
aws s3api copy-object --bucket my-bucket-abcdefg --key foo.txt --copy-source bucket1/foo.txt
Did you find this article helpful?
If so, consider buying me a coffee over at