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
- Alias (quick answer, line 1) —
mcstores the address and keys in~/.mc/config.json(mode 600). Use the root user only for setup. - Bucket with versioning — an overwritten or deleted file keeps its old version; together with the lifecycle rule old versions go away after 30 days.
- A user with a small policy — only this bucket, only what backups need:
{
"Version": "2012-10-17",
"Statement": [
{ "Effect": "Allow", "Action": ["s3:ListBucket"], "Resource": ["arn:aws:s3:::backups"] },
{ "Effect": "Allow", "Action": ["s3:GetObject", "s3:PutObject"], "Resource": ["arn:aws:s3:::backups/*"] }
]
}mc admin policy create s3 backup-writer backup-writer.json
mc admin user add s3 web1-backup 'LONG-RANDOM-SECRET'
mc admin policy attach s3 backup-writer --user web1-backupNo DeleteObject: a hacked server cannot delete its backups.
- Use the AWS CLI — any S3 tool works with the endpoint:
aws --profile minio --endpoint-url https://s3.example.com:9000 s3 cp report.csv s3://backups/web1/
aws --profile minio --endpoint-url https://s3.example.com:9000 s3 ls s3://backups/web1/- Share one file for a short time — a signed URL that expires:
mc share download --expire 2h s3/backups/web1/backup.tar.gz- Protect against ransomware — object lock (
mc mb --with-lockat creation, thenmc retention set --default GOVERNANCE 30d) makes objects undeletable for 30 days. - Watch it —
mc admin info s3(disks, health), and the Prometheus metrics endpoint for capacity alerts.
Check that it worked
mc ls lists the file; mc version info s3/backups shows versioning enabled; with the web1-backup keys an upload works but mc rm and access to other buckets fail with Access Denied; mc ilm rule ls s3/backups shows the rule.
Common problems
| Problem | Cause | Fix |
|---|---|---|
Access Denied for the new user | Policy covers bucket/* but not bucket (or the reverse). | List both resources as in the policy above. |
x509: certificate signed by unknown authority | Private CA. | Put the CA in the system trust store or ~/.mc/certs/CAs/. |
| AWS CLI goes to amazonaws.com | No --endpoint-url. | Add it, or endpoint_url in the profile. |
| Path-style errors with some tools | Tool expects virtual-host style. | Enable path-style (s3ForcePathStyle, addressing_style = path). |
| Disk fills although files were deleted | Versioning keeps old versions. | Noncurrent expiry rule; check mc du --versions. |
mc ilm command not found | Old mc with old syntax. | Update mc; current syntax is mc ilm rule add. |
Go further
- Command pages: mc, aws.
- Next how-tos: Back up Kubernetes with Velero, Back up a server with restic, Copy files to and from S3, Create a safe S3 bucket with Terraform.
- Learn it: Data services at work — MinIO. Full guide: MinIO.
1Why give the backup user no DeleteObject right?
If the server is hacked, the attacker can upload but cannot delete the existing backups.
2How do other S3 tools talk to MinIO?
They use the normal S3 API with MinIO's address as the endpoint URL.