config.yml
s3m reads credentials and host definitions from ~/.config/s3m/config.yml, or from the file given with -c/--config:
s3m --config /etc/s3m/config.yml ls backupEach object path starts with a host name from this file:
host/bucket/objectA minimal signed AWS host looks like this. Replace the example credentials with your own.
---
hosts:
backup:
region: us-east-2
access_key: ACCESSKEY
secret_key: SECRETKEYUse region for AWS-style hosts. Use endpoint for other S3-compatible vendors such as RustFS, MinIO, Backblaze B2, or Cloudflare R2.
Examples
---
hosts:
aws:
region: eu-central-2
access_key: AKIAZYSYPEXAMPLE
secret_key: dX8IEdhpIuzaFf3lexample
public:
region: us-east-2
cloudflare:
endpoint: 31675149903f5514779b45.r2.cloudflarestorage.com
access_key: ACCESSKEY
secret_key: SECRETKEY
backblaze:
endpoint: s3.us-west-001.backblazeb2.com
access_key: ACCESSKEY
secret_key: SECRETKEY
backup:
region: us-east-2
access_key: ACCESSKEY
secret_key: SECRETKEY
compress: true
enc_key: "12345678901234567890123456789012"
rustfs:
endpoint: http://127.0.0.1:9000
access_key: rustfsadmin
secret_key: rustfsadminThe rustfs host matches the local RustFS server started by just container in the s3m source repository.
TIP
For Cloudflare R2 check https://developers.cloudflare.com/r2/api/s3/tokens/ to obtain the access and secret key.
Upload using the backup host from the example above:
s3m /path/to/file backup/backups/test.txtIn that command:
backupis the host name fromconfig.ymlbackupsis the bucket nametest.txtis the object key
The target bucket must already exist unless you create it with s3m cb.
The bucket always comes from the path: a host has no default bucket. s3m ls cloudflare lists the buckets of that host, not the objects of a bucket. A bucket: key under a host is ignored (older READMEs showed it as an optional default bucket, but s3m never used it); configs that set it keep working.
Credentials
Each host needs access_key and secret_key. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY replace the config's keys when they are set. A host without keys (or with a misspelled one, such as acess_key:) stops before any request (exit 1):
hosts.cloudflare has no access_key in the config; set it, or use --no-sign-request for a public bucketFor a public bucket, use --no-sign-request and leave the keys out (see anonymous requests). share always needs the keys, because a presigned URL is signed.
Verbose logs don't print the signing credentials: with -vv, the request logs hide the values of the Authorization and X-Amz-Security-Token headers, and the configuration and host dumps show <redacted> for the access key ID.
Since 0.25.0
Before 0.25.0, a host without keys sent requests with an empty credential and got a signature error that didn't name the cause, and -vv could print the access key ID and the request signature.
Redirects
s3m doesn't follow redirects. A 3xx answer to any request is an error that shows:
- the HTTP status and the S3 error code
- the destination the server names, with any credentials, query and fragment removed (so a presigned URL can't leak into the output)
- the bucket's region, when the server sends it
A 301 (PermanentRedirect) means the host's endpoint or region doesn't match the bucket, and the error says to update them: fix the host in this file (see examples). A 307 (TemporaryRedirect) is described as applying to that request only.
A redirect is never retried, and s3m saves an upload's ETag only from a successful (2xx) answer, never from a redirect. ls, object-lock get and the HEAD request that checks an already uploaded file report the redirect instead of falling back to another way of answering.
Since 0.26.0
Before 0.26.0, s3m could follow a redirect: a 303 answer to an upload was followed with a GET, and the ETag of that answer was saved as the uploaded object's ETag.
HTTP and proxies
s3m talks to S3 over HTTP/1.1. It honours the HTTPS_PROXY and NO_PROXY environment variables:
HTTPS_PROXY=http://proxy.example.com:3128 s3m ls awsConnections, including the proxy's CONNECT, have the same 60-second connect limit as direct ones (see timeouts).
Monitor rules
You can define monitoring rules per host and then run:
s3m monitor <host>s3m monitor reads every bucket and rule under hosts.<host>.buckets.
---
hosts:
backup:
region: us-east-2
access_key: ACCESSKEY
secret_key: SECRETKEY
buckets:
bucket_A:
- prefix: backups/daily
suffix: .log
age: 1d
size: 30720
bucket_B:
- prefix: foo
age: 12h
size: 1024
- prefix: path/to/logs/
age: 12h
bucket_C:
- suffix: .sql # no prefix -> scans the whole bucket
age: 12hprefix is optional — omit it (or leave it empty) to scan the whole bucket; suffix, age, and size still apply.
age accepts integer seconds or suffixed durations:
30s15m12h7d
Set size: 0 to skip the minimum size check.
Show configured hosts
s3m showAWS policy
Example IAM policy to allow full access to one bucket:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::mybucket/*",
"arn:aws:s3:::mybucket"
]
}
]
}Where s3m keeps its files
By default s3m uses ~/.config/s3m for:
config.yml, when--configis not givenstreams/, the local state of multipart uploads (seestreams)
Set S3M_HOME to use another directory. It replaces ~/.config/s3m for both:
S3M_HOME=/var/lib/s3m s3m --config /etc/s3m/config.yml backup.tar backup/backups/backup.tars3m creates this directory only when an upload writes to it. Commands that keep no local state (ls, get, rm, show, ...) also work when the home directory is read-only or missing, for example in a container with a read-only root file system. Without a home directory, the fallback is .config/s3m in the system temp directory.

