# aws s3 cp

AWS CLI commands · Updated 16 November 2026

**Short answer:** aws s3 cp copies a file between your machine and S3, or between two S3 locations: aws s3 cp report.csv s3://my-bucket/reports/. Add --recursive to copy a whole directory or prefix, --exclude and --include to filter it, and --sse aws:kms to encrypt with a KMS key.

## What the command does

The source and destination decide the direction: local to `s3://` uploads, `s3://` to local downloads, and `s3://` to `s3://` copies server-side without passing data through your machine. Large files are split into parts and transferred in parallel automatically. Unlike [sync](https://cloudconsole.dev/cli/s3-sync), cp always copies, even if the destination already has an identical file.

## Syntax

```
aws s3 cp <source> <destination> \
  [--recursive] [--exclude "<pattern>"] [--include "<pattern>"] \
  [--sse AES256|aws:kms] [--sse-kms-key-id <key>] \
  [--storage-class STANDARD_IA|GLACIER_IR|...] \
  [--content-type <type>] [--cache-control <value>] [--dryrun]
```

## Worked examples

**Upload and download a single file:**

```
aws s3 cp ./backup.tar.gz s3://my-bucket/backups/2026-11-16/backup.tar.gz
aws s3 cp s3://my-bucket/reports/november.csv .
```

**Copy a directory recursively**, only the `.log` files:

```
aws s3 cp ./logs s3://my-bucket/logs/host-a/ --recursive \
  --exclude "*" --include "*.log"
```

Filters are applied in order and later ones win, so "exclude everything, then include *.log" is the standard pattern.

**Encrypt with a customer managed KMS key:**

```
aws s3 cp ./customers.csv s3://my-bucket/exports/ \
  --sse aws:kms --sse-kms-key-id alias/exports-prod
```

**Copy between buckets** (server-side) into a cheaper storage class:

```
aws s3 cp s3://prod-bucket/archive/ s3://archive-bucket/prod/ --recursive \
  --storage-class GLACIER_IR
```

**Stream from stdin and to stdout** with `-`:

```
pg_dump orders | gzip | aws s3 cp - s3://my-bucket/db/orders-$(date +%F).sql.gz
aws s3 cp s3://my-bucket/db/orders-2026-11-16.sql.gz - | gunzip | head
```

**Preview a recursive copy** without transferring anything:

```
aws s3 cp ./site s3://my-bucket/ --recursive --dryrun
```

## Errors and fixes

| Error | Cause |
|---|---|
| `AccessDenied` on `PutObject` | Missing `s3:PutObject`, a bucket policy deny (e.g. requiring encryption), or KMS: uploads with SSE-KMS need `kms:GenerateDataKey` on the key. See [S3 AccessDenied](https://cloudconsole.dev/errors/s3-access-denied) and [KMS AccessDenied](https://cloudconsole.dev/errors/kms-access-denied). |
| `AccessDenied` or 403 on download | Missing `s3:GetObject`, or `kms:Decrypt` for KMS-encrypted objects; see [403 on HeadObject](https://cloudconsole.dev/errors/s3-403-forbidden-headobject). |
| `[WinError 5] Access is denied` | A local Windows permission problem: the destination folder is not writable, a file is locked by another program, or the target is a directory. Nothing to do with S3. |
| `The specified key does not exist` | Wrong key or prefix; check with [s3 ls](https://cloudconsole.dev/cli/s3-ls), see [NoSuchKey](https://cloudconsole.dev/errors/s3-nosuchkey). |

## Gotchas

- **Trailing slashes change meaning.** `s3://b/dir` as a destination creates an object called `dir`; `s3://b/dir/` puts the file inside the prefix.
- **Recursive copies of huge prefixes** can take a long time and many requests. For bucket-to-bucket copies of millions of objects, S3 Batch Operations or replication are better tools.
- **Metadata on S3-to-S3 copies** is copied by default. To change content type or cache headers during a copy, add `--metadata-directive REPLACE` and specify all the metadata you want.
- **ACL flags may be rejected.** Buckets with ACLs disabled (the default for new buckets) refuse `--acl` values other than the owner-enforced ones.
- **Streams over 50 GB** need `--expected-size` so the CLI can choose a large enough part size.

## Questions

### How do I copy a folder to S3 recursively?

aws s3 cp ./folder s3://my-bucket/prefix/ --recursive. Use --exclude and --include to filter, or aws s3 sync if you only want to copy changed files.

### How do I upload a file with KMS encryption?

Add --sse aws:kms and optionally --sse-kms-key-id with a key ID, ARN or alias. You need kms:GenerateDataKey on that key.

### What is the difference between aws s3 cp and aws s3 sync?

cp copies everything you point it at, every time. sync compares source and destination and copies only new or changed files, and can delete extra files with --delete.

## When this happens away from your desk

A failed nightly backup upload usually turns up as a missing file the next morning. CloudConsole is built to put alarms, logs and resources on a phone so gaps like that show up sooner.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [aws s3 cp (AWS CLI Command Reference)](https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html)
- [Use high-level (s3) commands with the AWS CLI (User Guide)](https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html)

## Related

- [aws s3 sync](https://cloudconsole.dev/cli/s3-sync)
- [aws s3 mv](https://cloudconsole.dev/cli/s3-mv)
- [aws s3 ls](https://cloudconsole.dev/cli/s3-ls)
- [S3 AccessDenied: Access Denied when calling an S3 operation](https://cloudconsole.dev/errors/s3-access-denied)
- [KMS AccessDeniedException when reading an encrypted S3 object or secret](https://cloudconsole.dev/errors/kms-access-denied)
- [aws s3api head-object](https://cloudconsole.dev/cli/s3api-head-object)

---

Source: https://cloudconsole.dev/cli/s3-cp

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
