S3-compatible storage per TB · no API fees · encrypt before upload · pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Get storage

Tutorial · restic · 7 steps · checked 17 November 2026

How do I back up with restic to S3?

Last updated: · 4 min read

Quick answer

How do I back up with restic to S3?

Export the bucket's access key, secret key and region, point RESTIC_REPOSITORY at s3:https://endpoint/bucket, run restic init, then restic backup on a schedule. Test a restore and prune old snapshots. On a PrivateS3 bucket the whole setup takes 7 steps, and storage costs $2.23/TB-month on 12 months.

In brief
  • You need: restic installed, a bucket with its key pair, and a password you will never lose.
  • Time: about 15 minutes, plus the first upload.
  • Result: encrypted, deduplicated snapshots every night, kept 7 days, 5 weeks and 12 months.
  • Values: the endpoint and region are shown with the keys in the client area; examples use https://s3.privates3.com and eu-central-1.

Which restic commands does this guide use?

The restic commands in this guide, what each does, and when to run it
CommandWhat it doesWhen
restic initCreates the encrypted repository in the bucketOnce
restic backupUploads changed data as a new snapshotEvery night
restic snapshotsLists snapshotsAfter each change of setup
restic restoreWrites a snapshot back to diskOnce a month as a test
restic forget --pruneDrops old snapshots and frees spaceWeekly
restic checkVerifies the repository's structureAfter each prune

Step 1–2: how do you store the keys and password safely?

Put them in a root-only file, then load it before each restic command. The restic manual, read on 17 November 2026, takes S3 keys from AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, the region from AWS_DEFAULT_REGION, and the server from a repository URL of the form s3:https://server:port/bucket_name.

The repository password goes in a second file. Restic's manual is blunt: losing it means the data is lost for good. Copy it to a password manager now. The keys come from the client area once the bucket is ready; the access keys help page shows where.

/root/.restic-env (chmod 600)
export AWS_ACCESS_KEY_ID=ACCESS_KEY
export AWS_SECRET_ACCESS_KEY=SECRET_KEY
export AWS_DEFAULT_REGION=eu-central-1
export RESTIC_REPOSITORY=s3:https://s3.privates3.com/BUCKET/restic
export RESTIC_PASSWORD_FILE=/root/.restic-password

Step 3–4: how do you create the repository and run the first backup?

Load the file, run restic init once, then restic backup with the folders to save. Init writes the repository's encrypted config and keys into the bucket. The first backup uploads everything; later runs send only changed chunks.

Dump databases first so the backup holds a consistent copy, and exclude caches with an exclude file.

Create the repository and back up
. /root/.restic-env
restic init

mysqldump --all-databases > /root/db-dumps/all.sql
restic backup /etc /var/www /root/db-dumps --exclude-file=/root/.restic-excludes
restic snapshots

Step 5: how do you run the backup every night?

With a cron job that loads the file, backs up, then prunes once a week. Write a small script and call it from root's crontab. The forget policy below follows the example in restic's manual on removing snapshots: daily, weekly and monthly snapshots kept for set counts.

/root/restic-nightly.sh and the crontab line
#!/bin/sh
set -e
. /root/.restic-env
restic backup /etc /var/www /root/db-dumps --exclude-file=/root/.restic-excludes
if [ "$(date +%u)" = 7 ]; then
  restic forget --keep-daily 7 --keep-weekly 5 --keep-monthly 12 --prune
  restic check
fi

# crontab -e (root)
30 2 * * * /root/restic-nightly.sh >> /var/log/restic.log 2>&1

Step 6: how do you test a restore?

Restore the latest snapshot into a scratch folder and compare a few files. The restic manual shows restic restore with a snapshot ID or latest and a --target folder; --include limits the restore to one path. A backup never restored is a guess, so repeat this every month.

Restore test
. /root/.restic-env
restic restore latest --target /tmp/restore --include /etc/nginx
diff -r /etc/nginx /tmp/restore/etc/nginx && echo restore-ok

Step 7: how do you protect the backups from deletion?

Turn on bucket versioning, or ask for Object Lock, so a compromised server cannot erase history. Restic's design document says it does not protect against deletion at the storage location. At PrivateS3, versioning is self-service: S3 versioning can be turned on per bucket from any S3 client; old versions count toward the quota. Locking is not: Object Lock (immutable backups) is set on a new bucket on request through a support ticket.

Versioning keeps deleted pack files as old versions, which also count toward the quota. The versioning guide covers the command and a cleanup rule. According to PrivateS3's survey of 17 November 2026, Wasabi bills deleted data until day 90 and Storj until day 30; PrivateS3 has no minimum storage duration, so the weekly prune frees quota at once.

restic to S3: common questions

Restic says the repository already exists. What now?

The bucket path already holds a repository. Use a new folder in RESTIC_REPOSITORY, or run backups against the existing one with its password.

Do I need path-style access?

Only if requests fail with DNS errors. Add -o s3.bucket-lookup=path, documented in the restic manual.

Can two servers share one repository?

Yes. Restic deduplicates across hosts and tags each snapshot with its host name; prune from one server only.

What if the bucket fills up?

The upload fails with a quota error and nothing is billed. Prune, or move to a bigger plan.

How do I mount snapshots to browse them?

restic mount /mnt/restic exposes snapshots as folders on Linux and macOS, per the restic manual.

Verdict
  • Seven steps give a server encrypted nightly backups on an S3-compatible bucket, with pruning and a monthly restore test.
  • On PrivateS3 that costs $2.23/TB-month on 12 months, with no fee when restic prunes or restores. See restic storage on PrivateS3.
Sources (4)
  1. Preparing a new repository (Amazon S3) — restic documentation (read 17 November 2026)
  2. Restoring from backup — restic documentation (read 17 November 2026)
  3. Removing backup snapshots — restic documentation (read 17 November 2026)
  4. References: design — restic documentation (read 17 November 2026)

A bucket for restic: 1 TB for 12 months, $26.77

Keys within 24 hours, no fee to prune or restore, paid in crypto.

$5.40/TB-month · no KYC

Get storage