Mad World #Save_GAZA: Free Palestine  

Search

Restic Backup to Cloudflare R2 for Production (2026): Signed Install, Encrypted Snapshots, Restore, Retention and the Backrest Web GUI, Tested

Restic Backup to Cloudflare R2 for Production (2026): Signed Install, Encrypted Snapshots, Restore, Retention and the Backrest Web GUI, Tested

restic is a free, open-source backup program. One command copies your folders into a repository, encrypted on your machine with a password only you know, and every later backup sends only what changed. Cloudflare R2 is Cloudflare's object storage: it speaks the same S3 API as Amazon S3 and charges nothing for downloads, which is what a restore is. Backrest is a free web interface for restic: it schedules the backups, applies the retention policy, sends alerts and restores files from the browser.

This guide sets the three up for production on one server: a token that can reach one bucket only, restic installed from its signed release, the keys in files only you can read, a backup and a tested restore, an integrity check, a retention policy, then Backrest in Docker with a daily plan and alerts on your phone. Tested on 26 November 2026 on an Ubuntu 26.04.1 laptop with restic 0.20.0 and Backrest 1.14.1, against an R2 bucket of NexaForge, our test Cloudflare account, within R2's free monthly allowance. Every command below ran there, and every screenshot shows its real output.

Quick answer: restic backups to Cloudflare R2

In plain words: restic needs three things to back up to R2: the bucket's S3 address, a key pair that can write to that bucket, and a password that encrypts the repository. Keep the three in files only your user can read, then:

  1. In the Cloudflare dashboard, create an R2 bucket and an Account API token with Object Read & Write on that bucket only.
  2. Install restic 0.20.0 from its GitHub release and check the signature (Ubuntu 26.04's package is 0.18.1).
  3. Put the keys and the repository address in an env file with mode 600, and a random password in its own file.
  4. Run restic init once, then restic backup for each backup.
  5. Restore to a new folder and compare it with the original. Until a restore has worked, you do not know that the backup works.
  6. Run restic check --read-data-subset every month.
  7. Apply a retention policy with restic forget --prune.
  8. For schedules, alerts and restores in a browser, run Backrest in Docker on the same repository.
Terminal: restic snapshots lists three snapshots in the R2 repository: one from the laptop with tag site, two from Backrest with tags plan:site-daily and created-by:web-01
The result: one encrypted repository in R2. 1: snapshots from the restic command line and from Backrest's daily plan, side by side.

What Cloudflare R2 costs for restic backups in 2026

R2 bills storage and requests, never downloads. These are Cloudflare's published prices, checked on 26 November 2026:

Free each monthStandard storageInfrequent Access
Storage10 GB-month$0.015 per GB-month$0.01 per GB-month
Class A operations (writes and lists)1 million$4.50 per million$9.00 per million
Class B operations (reads)10 million$0.36 per million$0.90 per million
Data retrievalNoneNone$0.01 per GB
Downloads (egress)FreeFreeFree
Minimum storage durationNoneNone30 days

The free allowance only applies to Standard storage. Keep a restic repository there: restic reads its index and data files during check, prune and restore, and Infrequent Access charges for every GB read, plus 30 days of storage for files that prune deletes sooner. In this test, 107 MiB of website files took 42 MiB in the bucket, far inside the free 10 GB-month. At 100 GB of backups, storage costs about $1.35 a month (90 GB above the free part, at $0.015).

Step 1: an R2 bucket and a token for that bucket only

In the Cloudflare dashboard, open Storage & databases > R2 Object Storage and select Create bucket. The name is permanent. Leave the location on Automatic and the storage class on Standard, then select Create bucket.

Cloudflare dashboard, R2 Object Storage, Create a bucket: name nexaforge-backups, location Automatic, default storage class Standard
1: the bucket name, which you cannot change later. 2: Automatic location. 3: Standard storage, the class with the free allowance.

Now create the key pair restic will use. In R2 Object Storage, select Manage API tokens, then Create Account API token. An account token belongs to the Cloudflare account, not to a person, so it keeps working if the person who made it leaves. Give it the permission Object Read & Write (read, write and list objects, nothing else) and, under Specify bucket(s), choose Apply to specific buckets only with your backup bucket. The Admin permissions cover every bucket of the account, and Admin Read & Write can also delete buckets: a stolen key would reach all of them.

If your server has a fixed public IP address, add it under Client IP Address Filtering, so the token works from that address only. TTL Forever suits a server that backs up every night; replace the token when someone who had a copy leaves.

Cloudflare dashboard, Create Account API Token for R2: name restic-backups, permission Object Read & Write, only the nexaforge-backups bucket, TTL Forever, client IP address filtering
1: a name you will recognise. 2: Object Read & Write, the smallest permission that can back up. 3: this bucket only. 4: optional, the server's IP address.

The next page shows the credentials once. restic needs three of them: the Access Key ID, the Secret Access Key and the S3 endpoint, https://<ACCOUNT_ID>.r2.cloudflarestorage.com. Copy them into a password manager now: Cloudflare does not show the secret again.

Cloudflare dashboard after creating the R2 token restic-backups: Object Read & Write on nexaforge-backups, then the Access Key ID, the Secret Access Key and the S3 endpoint for S3 clients
1: the Access Key ID. 2: the Secret Access Key. 3: the S3 endpoint, with your account ID. restic uses these three, not the token value above them.

Step 2: install restic 0.20.0 and check its signature

Ubuntu 26.04 offers restic 0.18.1, two releases behind. restic's own release is one static file per platform, signed by the project's maintainer. Download the file, the checksum list and its signature, import the key from restic.net and verify:

Code
apt-cache policy restic | head -3
curl -sLO https://github.com/restic/restic/releases/download/v0.20.0/restic_0.20.0_linux_amd64.bz2
curl -sLO https://github.com/restic/restic/releases/download/v0.20.0/SHA256SUMS
curl -sLO https://github.com/restic/restic/releases/download/v0.20.0/SHA256SUMS.asc
curl -s https://restic.net/gpg-key-alex.asc | gpg --import
gpg --verify SHA256SUMS.asc SHA256SUMS
Terminal: apt-cache policy shows candidate 0.18.1-3ubuntu1; curl downloads restic 0.20.0, SHA256SUMS and its signature; gpg imports two keys and reports a good signature, fingerprint CF8F 18F2 ... D3F7 A907
1: Ubuntu's package. 2 to 4: the release file, the checksums and their signature. 5: the release key. 6: a good signature, and the fingerprint to compare.

What counts is "Good signature" and the key fingerprint, CF8F 18F2 8445 7597 3F79 D4E1 91A6 868B D3F7 A907: compare it with the one on restic's installation page. The warning below it only says that you have not certified this key yourself in GPG. The key file holds two keys of the same maintainer; the release is signed by 91A6868BD3F7A907. Then check the file's checksum, unpack it and install it:

Code
sha256sum --ignore-missing -c SHA256SUMS
bunzip2 restic_0.20.0_linux_amd64.bz2
sudo install -m 755 restic_0.20.0_linux_amd64 /usr/local/bin/restic
restic version
sudo restic self-update
Terminal: sha256sum reports restic_0.20.0_linux_amd64.bz2: OK; bunzip2 and sudo install put restic in /usr/local/bin; restic version 0.20.0 with go1.27.4; self-update finds restic up to date
1: the checksum matches. 2 and 3: unpack and install. 4: the version. 5: self-update, which also checks the signature.

--ignore-missing checks only the file you downloaded, not every platform in the list. restic self-update replaces the binary with the newest release after checking its GPG signature itself; it needs sudo because the binary sits in /usr/local/bin. Here it found nothing newer.

Step 3: the keys, the password and the repository

restic reads its settings from environment variables. Keep them in a file, not in a script or your shell history. Create ~/.config/restic/r2.env with your editor, with your own keys, account ID and bucket:

.env
AWS_ACCESS_KEY_ID=<Access Key ID>
AWS_SECRET_ACCESS_KEY=<Secret Access Key>
RESTIC_REPOSITORY=s3:https://<ACCOUNT_ID>.r2.cloudflarestorage.com/nexaforge-backups
RESTIC_PASSWORD_FILE=/home/dev/.config/restic/password

RESTIC_REPOSITORY is s3: followed by the endpoint and the bucket name. RESTIC_PASSWORD_FILE points to the repository password: restic encrypts every file, folder name and snapshot with it, on your machine, before anything leaves. Lock both files to your user, create a random password and the repository:

Terminal
chmod 700 ~/.config/restic
openssl rand -base64 32 > ~/.config/restic/password
chmod 600 ~/.config/restic/password ~/.config/restic/r2.env
ls -l ~/.config/restic
cut -d= -f1 ~/.config/restic/r2.env
set -a; . ~/.config/restic/r2.env; set +a
restic init
Terminal: chmod 700 and 600 on the restic config folder, a random password from openssl rand, ls -l shows password and r2.env as -rw-------, cut lists four variable names, restic init creates the repository
1 to 3: a private folder, a random password, both files readable by you only. 4 and 5: the check, without printing a secret. 6: load the file. 7: create the repository.

ls -l and cut -d= -f1 check the files without printing a secret. set -a; . ~/.config/restic/r2.env; set +a exports every line of the file to the commands that follow; run it again in each new shell before a restic command, as the next steps assume. restic init writes the repository's configuration and encrypted key into the bucket. Read its warning twice: without the password, nobody can read the backups, you included. Keep a copy of the password in a password manager or on paper, away from this server.

Step 4: the first backup, then the second

The test site is a typical small website: a 64 MB database dump, 5 MB of pages and 41 MB of uploaded media. Back it up with a tag, so you can filter snapshots later:

Code
du -sh ~/site/*
restic backup ~/site --tag site
Terminal: du -sh shows db 64M, docs 5.0M, uploads 41M; the first restic backup reads 309 files (107.286 MiB), adds 106.105 MiB, 42.037 MiB stored, snapshot a75ac3c8 saved
1: what the site holds. 2: the first backup: 107 MiB of files, 42 MiB stored in R2.

restic read 309 files (107.286 MiB) and added 106.105 MiB of new data, which took 42.037 MiB in the bucket after compression: the SQL dump shrinks a lot, the media files hardly at all. The run took 10 seconds and saved snapshot a75ac3c8. Now change one line of the database dump and back up again, as the nightly job would:

Terminal
echo 'INSERT INTO log VALUES (2000001);' >> ~/site/db/site.sql
restic backup ~/site --tag site
restic snapshots
Terminal: after one line is added to site.sql, the second backup finds 1 changed and 308 unmodified files and adds 326.320 KiB (7.028 KiB stored); restic snapshots lists two snapshots
1: one change in the database dump. 2: only the changed part is sent. 3: two full snapshots.

restic found 1 changed file and 308 unmodified ones. Of the 64 MB dump, it sent only the changed chunks: 326.320 KiB of new data, 7.028 KiB once compressed. That is deduplication: each snapshot is a full backup you can restore on its own, but it costs only the changes. restic snapshots lists both.

Step 5: restore everything, then one file

Restore to a new folder, never over the live site, and compare:

Code
restic restore latest --target ~/restore
diff -r --no-dereference ~/site ~/restore/home/dev/site && echo identical
restic restore latest --target ~/restore-one --include /home/dev/site/db/site.sql
ls -l ~/restore-one/home/dev/site/db/
Terminal: restic restore latest restores 607 files and folders (107.286 MiB) in 0:04, diff prints identical, a restore with --include brings back site.sql alone (63.790 MiB)
1: the whole snapshot to a new folder. 2: no difference with the original. 3 and 4: one file only.

The restore rebuilt 607 files and folders (107.286 MiB) in 4 seconds, and diff found no difference. restic keeps the full original path under the target, here ~/restore/home/dev/site. --no-dereference makes diff compare links as links: without it, diff reports an error for each link that points to a missing file. For a single file, add --include with its full path: the 64 MB dump came back alone in one second.

Step 6: check the repository and part of the data

Code
restic check
restic check --read-data-subset=25%
Terminal: restic check ends with no errors were found; restic check --read-data-subset=25% reads 25.0% of packfiles and finds no errors
1: the structure check. 2: the same, plus a quarter of the data downloaded and verified.

restic check verifies the structure: the index, the snapshots, and that every piece they need exists. --read-data-subset=25% also downloads a random quarter of the data files and verifies their content, which catches silent corruption. On R2 the download is free; only the read requests count, and 10 million of them a month are free. Each run picks another random part, so monthly checks cover more and more of the repository.

Step 7: keep 7 daily, 4 weekly and 6 monthly snapshots

restic forget removes snapshots according to a policy, and --prune deletes the data that no snapshot uses anymore. Try a policy with --dry-run first:

Code
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --dry-run
Terminal: restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --dry-run keeps both snapshots, the first one as the oldest daily, weekly and monthly snapshot
1: the policy, tried without changing anything: both snapshots stay, and the reasons column says why.

The policy keeps one snapshot per day for 7 days, one per week for 4 weeks and one per month for 6 months: at most 17 snapshots and about half a year of history. On the first day it removes nothing, and the output says why: when there are fewer snapshots than the policy asks for, restic also keeps the oldest one, marked oldest daily, weekly and monthly snapshot.

To see prune at work, this test kept only the last snapshot. Do not run --keep-last 1 on a real repository unless you mean it:

Code
restic forget --keep-last 1 --prune
restic snapshots
Terminal: restic forget --keep-last 1 --prune removes snapshot a75ac3c8, prune removes 5 blobs (2.817 KiB) and keeps 515 blobs (42.021 MiB); restic snapshots lists one snapshot
1: forget removes the older snapshot, then prune deletes the data only it used. 2: one snapshot left.

forget removed a75ac3c8, then prune found 5 blobs (2.817 KiB) that only that snapshot used, repacked the pack files that held them and removed one old pack. Most of the first snapshot's data stayed, because c7145437 still uses it: 515 blobs, 42.021 MiB. Prune reads and rewrites data, so run it weekly or monthly, not after every backup.

Step 8: two errors you will meet

Code
restic snapshots --password-file /tmp/wrong-password
RESTIC_REPOSITORY=${RESTIC_REPOSITORY%/*}/other-bucket restic snapshots
Terminal: a wrong password file gives Fatal: wrong password or no key found; another bucket name gives Stat: Access Denied and Fatal: unable to open config file
1: a wrong password. 2: a bucket the token does not cover.

A wrong password gives Fatal: wrong password or no key found: check RESTIC_PASSWORD_FILE and the file it names. The second command swaps the bucket name for other-bucket for one run (${RESTIC_REPOSITORY%/*} is the address without its last part). With a token limited to one bucket, R2 answers Access Denied for any other name, even one that does not exist, so a typo in the bucket name looks like a permission problem. If you see Stat: Access Denied, compare the bucket in RESTIC_REPOSITORY with the token's bucket list.

Step 9: run Backrest with Docker Compose

Backrest runs restic for you: it schedules backups, applies the retention policy, runs check and prune, sends alerts and restores files from the browser. Its Docker image includes restic (0.19.1 in Backrest 1.14.1), so the server needs only Docker with the Compose plugin; Install Docker Compose on Ubuntu covers that. This compose file follows the one in Backrest's README, with a pinned version, the port bound to the machine itself and the data mounted read-only:

YAML
services:
  backrest:
    image: ghcr.io/garethgeorge/backrest:v1.14.1
    container_name: backrest
    hostname: backrest
    restart: unless-stopped
    env_file: backrest.env
    environment:
      - BACKREST_DATA=/data
      - BACKREST_CONFIG=/config/config.json
      - XDG_CACHE_HOME=/cache
      - TMPDIR=/tmp
      - TZ=America/New_York
    volumes:
      - ./data:/data
      - ./config:/config
      - ./cache:/cache
      - ./tmp:/tmp
      - ../site:/userdata/site:ro
    ports:
      - "127.0.0.1:9898:9898"

The keys stay in a separate file, backrest.env, next to it: the same values as in step 3, and the repository password itself, the content of ~/.config/restic/password:

.env
R2_ACCOUNT_ID=<ACCOUNT_ID>
R2_ACCESS_KEY_ID=<Access Key ID>
R2_SECRET_ACCESS_KEY=<Secret Access Key>
RESTIC_REPO_PASSWORD=<the repository password>

Check the names, lock the file and start Backrest:

Terminal
cat compose.yaml
cut -d= -f1 backrest.env
chmod 600 backrest.env && stat -c "%a %n" backrest.env
Terminal: cat compose.yaml shows the Backrest service pinned to v1.14.1, an env file, data, config and cache volumes, the site mounted read-only and port 127.0.0.1:9898; backrest.env holds four variables, mode 600
1: the compose file. 2: the variable names in backrest.env. 3: the file readable by its owner only.
Terminal
docker compose up -d
docker compose ps
Terminal: docker compose up -d creates the network and starts the backrest container; docker compose ps shows it up on 127.0.0.1:9898
1: start. 2: Backrest 1.14.1 runs, reachable from this machine only.

TZ sets the clock Backrest's schedules follow: put your own time zone. /data, /config and /cache keep Backrest's state on the host, so it survives an update. ../site:/userdata/site:ro is the folder to back up, read-only inside the container: Backrest can read it, never change it. 127.0.0.1:9898 keeps the web interface off the network; reach it through an SSH tunnel, or put it behind Cloudflare Access with a hostname of its own.

Step 10: first start, instance ID and login

Open http://127.0.0.1:9898. Backrest first asks for an instance ID: it names this installation in the snapshots' tags (created-by:web-01 here) and cannot be changed later, so use the server's name. On our first start, Disable Authentication was switched on, which means no login at all. Switch it off, add a user with a long password, then Save changes.

Backrest 1.14.1 settings on first start: instance ID web-01, the Disable Authentication switch turned off, user admin with a password
1: the instance ID, which you cannot change later. 2: Disable Authentication off, so Backrest asks for a login. 3 and 4: the user and its password.

Backrest keeps the password as a bcrypt hash in config/config.json, a file it creates with mode 600.

Step 11: add the R2 repository without pasting the keys

Select Add Repo. Backrest expands ${NAME} references from its own environment, so the keys stay in backrest.env and Backrest's configuration only holds their names. Enter these values, with your bucket name, in Repository URI and Env Vars:

Code
s3:https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com/nexaforge-backups
AWS_ACCESS_KEY_ID=${R2_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY=${R2_SECRET_ACCESS_KEY}
RESTIC_PASSWORD=${RESTIC_REPO_PASSWORD}
Backrest Add Restic Repository: URI s3:https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com/nexaforge-backups and three env vars that reference the R2 keys and the repository password
1: the repository address, with the account ID read from backrest.env. 2 and 3: the R2 keys. 4: the repository password. The Password field stays empty.

In Scheduling, keep the prune policy monthly with Max Unused After Prune at 10, and set the check policy to read 10% of the data, also monthly:

Backrest repository scheduling: prune policy with Max Unused After Prune 10 and the cron expression 0 0 1 * *, at 12:00 AM on day 1 of the month
1: prune leaves at most 10% of unused space. 2: once a month.
Backrest repository scheduling: check policy with Read Data 10 percent and the cron expression 0 0 1 * *, once a month
1: each check also downloads and verifies 10% of the data. 2: once a month.

Test Configuration answered "Connected successfully to s3:https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com/nexaforge-backups and found an existing repo": Backrest found the repository that restic init created in step 3. Select Submit, open the repository and select Index Snapshots to list the snapshots made from the command line:

Backrest repository r2-site after Index Snapshots: prune and check scheduled for 12/01/2026, and the command line snapshot c7145437 of 107.29 MiB listed
1: Index Snapshots reads what is already in the repository. 2: the snapshot from step 4, made with the command line.

Backrest's config.json now holds ${R2_SECRET_ACCESS_KEY}, not the key: we searched the file for each secret value and found none.

Step 12: a daily plan with retention and alerts

Select Add Plan. A plan says what to back up, where and when:

Backrest Add Plan: plan name site-daily, repository r2-site, path /userdata/site, exclude pattern *.tmp
1: the plan name, which you cannot change later. 2: the repository. 3: the folder mounted read-only. 4: files to leave out.
Backrest plan schedule: cron expression 30 2 * * *, at 02:30 AM, reference clock Local
1: every day at 02:30. 2: Local time, from TZ in the compose file.

Pick a quiet hour. If the site has a database, back up a dump of it, like site.sql in this test, not the database's live files, and make the dump before 02:30.

Backrest plan retention policy By Time Period: hourly 0, daily 7, weekly 4, monthly 6, yearly 0
1: a policy by time period. 2 to 4: 7 daily, 4 weekly and 6 monthly snapshots, as in step 7.

Backrest applies this policy with restic forget after each backup; the repository's monthly prune then deletes the data.

Under Advanced, add a hook of type Shoutrrr for alerts. This one posts to ntfy, a free push service with Android and iOS apps: subscribe to your topic in the app, and Backrest's messages reach your phone. On the public ntfy.sh server, anyone who knows a topic name can read it, so make the name long and random. The success message is useful too: a morning without it means the night's backup did not run.

Backrest plan hook: Shoutrrr on CONDITION_ANY_ERROR and CONDITION_SNAPSHOT_SUCCESS, sending to an ntfy.sh topic
1: an alert on any error and on each successful snapshot. 2: the ntfy address of your topic.

Step 13: run the plan once

Open the plan and select Backup Now. The first run from Backrest added only 207.51 KiB, though the folder holds 107 MiB: it had the same content as the command line's snapshot, and restic stores each piece once, whatever host or path it comes from. A second run added 371 bytes:

Backrest plan site-daily after Backup Now: snapshot 8e594519 with tags plan:site-daily and created-by:web-01, 309 files unmodified, 371 B added, a forget step that removed 0 snapshots
1: run the plan now. 2: nothing changed in the 309 files. 3: 371 bytes added. 4: the tags Backrest adds.

ntfy received the message within seconds, here in the ntfy.sh web app:

ntfy web app showing the Backrest snapshot notification: plan site-daily, event snapshot success, data added 371 B, 309 files processed, none new or changed
1: the message: the plan, the snapshot and what it added.

The first run's alert did not arrive: the hook timed out. The cause and the fix are under Errors and fixes below.

Step 14: restore a file from Backrest

Open the snapshot in the plan's tree view, find the file in Snapshot Browser, open its menu and select Restore to path. The path is inside the container: /tmp is the ./tmp folder of the compose project on the host. Choose a folder that does not exist yet: Backrest overwrites files already at that path.

Backrest dialog Restore /userdata/site/db/site.sql with the target path /tmp/restore and the Restore button
1: the target folder, inside the container. 2: Restore, then Confirm Restore? on the same button.
Backrest restore details: source /userdata/site/db/site.sql, destination /tmp/restore, 63.79 MiB of 63.79 MiB done, 1 of 1 file, and a Download File(s) button
1: the file. 2: where it went. 3: all of it. 4: the same file can go to your browser instead.

Then compare the restored file with the original:

Terminal
docker compose exec backrest sha256sum /userdata/site/db/site.sql /tmp/restore/site.sql
Terminal: sha256sum inside the backrest container prints the same hash for /userdata/site/db/site.sql and the restored /tmp/restore/site.sql
1: the same SHA-256 hash for the original and the restored file.

Run the comparison inside the container, as above: on the host, the restored files belong to root, because Backrest runs restic as root.

Errors and fixes

ErrorCauseFix
Fatal: wrong password or no key foundThe password does not open this repositoryCheck RESTIC_PASSWORD_FILE, or RESTIC_REPO_PASSWORD in backrest.env
Fatal: unable to open config file: Stat: Access Denied.A wrong bucket name, or a token without this bucketCompare RESTIC_REPOSITORY with the token's bucket list
context deadline exceeded (Client.Timeout exceeded while awaiting headers)The hook's HTTPS request leaves Docker in packets too big for the host's linkLower the Docker network MTU (below)
Restore in Backrest does nothingThe button asks for a second clickSelect it again when it reads Confirm Restore?
diff reports No such file or directory for linksLinks to missing files, which diff followsAdd --no-dereference
Permission denied on restored files from the hostBackrest restores as rootCheck them with docker compose exec backrest or sudo

The ntfy alert times out from Docker: lower the MTU

Backrest's first alert failed with Post "https://ntfy.sh/<topic>": context deadline exceeded (Client.Timeout exceeded while awaiting headers). The test machine's link to the internet carries packets of at most 1,408 bytes, and Docker's bridge network uses 1,500: the large TLS packets from the container were lost on the way. VPN links, PPPoE connections and some cloud networks have the same limit. Give the compose network a smaller MTU in compose.override.yaml, next to compose.yaml, and recreate the container:

YAML
networks:
  default:
    driver_opts:
      com.docker.network.driver.mtu: "1400"
Terminal
docker compose down
docker compose up -d
docker compose exec backrest cat /sys/class/net/eth0/mtu
Terminal: compose.override.yaml sets the default network MTU to 1400; docker compose down and up -d recreate the container; its eth0 interface reports 1400
1: the override file. 2 and 3: recreate the network and the container. 4: the container now uses 1400.

Docker Compose reads compose.override.yaml on its own. After the change, the container's interface reported 1400 and the next alert arrived.

Production checklist

  • The R2 token: an Account API token with Object Read & Write on one bucket, limited to the server's IP address when it is fixed.
  • restic from the signed release, kept current with sudo restic self-update; Backrest on a pinned version tag that you update on purpose.
  • r2.env, the password file and backrest.env in mode 600, never in a Git repository.
  • A copy of the repository password away from the server.
  • A database dump before each backup, not the live database files.
  • A check every month that reads part of the data (10% here), and a prune every month.
  • A restore test every month: one file and a comparison, as in steps 5 and 14.
  • Alerts on errors and on success; a missing success message is an alert too.
  • Backrest's login on, its port on 127.0.0.1, and an SSH tunnel or Cloudflare Access to reach it.
  • One more copy that the server's key cannot delete (see the last question below).

Frequently asked questions

Is restic free, and what does Cloudflare R2 cost for backups?

restic is free and open source, under the BSD 2-Clause license, and so is Backrest. You pay only for the storage: R2 gives 10 GB-month of Standard storage free each month, then charges $0.015 per GB-month, with no fee for downloads. 100 GB of backups costs about $1.35 a month in storage, plus requests, which nightly backups of a small site keep inside the free allowance.

Does restic encrypt the data before it reaches R2?

Yes. restic encrypts on your machine with AES-256 in counter mode and authenticates every piece with Poly1305-AES, with keys protected by your repository password. R2 only receives encrypted data, so neither Cloudflare nor anyone with the bucket keys can read your files without the password.

What is Backrest, and do I still need the restic command line?

Backrest is a web interface and scheduler for restic: it runs restic underneath and keeps its settings in config.json. The repository stays a normal restic repository: in this test, the command line listed Backrest's snapshots next to its own, as the first screenshot shows. Keep the command line for scripts and emergencies; the browser covers the daily work.

How do I restore a single file with restic?

Pass --include with the file's full path: restic restore latest --target ~/restore-one --include /home/dev/site/db/site.sql restored the 64 MB dump alone in one second in step 5. In Backrest, open the snapshot, find the file in Snapshot Browser and select Restore to path, as in step 14.

Can restic back up to R2 through rclone?

restic can use rclone as a backend (rclone:remote:path), which helps with storage that has no S3 API. R2 does not need it: restic's own S3 backend talks to R2 directly, as in this guide, with one program less to install and update.

What happens if I lose the repository password?

The backups are lost. restic cannot decrypt them without it, and there is no reset: R2 holds only encrypted data. A repository can have more than one password (restic key add), so you can keep a second one in a separate safe place.

Can an attacker on the server delete the backups?

Yes. The key on the server can write and delete objects in the bucket, so anyone who gets root on the server can delete the backups too. R2 bucket locks stop the deletion and overwriting of objects for a set period, but restic's prune then cannot remove locked data either, so test them on a separate bucket first. The simpler protection is a second copy that this server's key cannot reach.

Sources

Yassine

Yassine

Yassine founded IGProd to educate the visitors with technological tutorials. These helpful guides are available for all sorts of professionals and novices, whether they work in technology or not!

Surf freely 💗

Leave a comment

Your email address will not be published. Required fields are marked *

Your experience on this site will be improved by allowing cookies Cookie Policy