Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
Step by step
- Log in and check the target (account, bucket, region):
- Copy single files or folders:
| Command | Does |
|---|---|
aws s3 cp FILE s3://B/path/ | Upload one file. |
aws s3 cp s3://B/path/FILE . | Download one file. |
aws s3 cp ./logs s3://B/logs/ --recursive | Upload a whole folder. |
aws s3 mv s3://B/a s3://B/b | Move or rename inside S3. |
aws s3 rm s3://B/old/ --recursive | Delete (careful — check with --dryrun). |
- Sync like
rsync— only new and changed files. Always--dryrunbefore--delete:
aws s3 sync ./dist s3://acme-site/ --delete --dryrun
(dryrun) upload: dist/index.html to s3://acme-site/index.html
(dryrun) delete: s3://acme-site/old.js
aws s3 sync ./dist s3://acme-site/ --delete --exclude "*.map" --cache-control "max-age=300"- Encrypt and choose the storage class (backups that are rarely read cost less in a colder class):
aws s3 cp db-2026-11-19.sql.gz s3://acme-backups/db/ --sse aws:kms --storage-class STANDARD_IA- Share one file for a limited time — a pre-signed URL (no public bucket needed):
aws s3 presign s3://acme-backups/reports/q3.pdf --expires-in 3600Anyone with the link can download for 1 hour — send it only to the right person.
- Big copies: large files are uploaded in parts automatically. Make it faster with more parallel requests:
aws configure set default.s3.max_concurrent_requests 20Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
An error occurred (AccessDenied) | The role has no s3:PutObject/GetObject on that path, or a bucket policy blocks it. | Check the profile; ask for access to that prefix only. |
AccessDenied only with --sse aws:kms | No rights on the KMS key. | Add kms:Encrypt/kms:GenerateDataKey (and kms:Decrypt to read). |
NoSuchBucket | Typo, or another account. | aws s3 ls; check the profile/account. |
PermanentRedirect / wrong region | The bucket is in another region. | Add --region with the bucket's region. |
--delete removed files you needed | Wrong source folder or missing slash. | Always --dryrun first; turn on bucket versioning to undo deletes. |
| Upload is slow | Few parallel requests, far region. | max_concurrent_requests; a bucket in a near region. |
Go further
- Command pages: aws.
- Next how-tos: Find public S3 buckets, Log in to AWS with SSO, Copy files between servers.
- Full guides: AWS CLI, restic backups to S3, MinIO (S3 on your own server).
- At work: Backups and the 3-2-1 rule.
- Practise: Lab: prove the backup restores.
1What is the difference between aws s3 cp --recursive and aws s3 sync?
cp copies everything every time; sync copies only new and changed files (and with --delete also removes extra files).