Restic Docker backup
for volumes, offsite

Updated November 2026

Back up bind mounts, named volumes and databases with restic over HTTPS: encrypted, deduplicated and offsite.

On this page

The right approach for Docker backups with restic

Docker data lives in three places. Bind mounts are host directories restic can read directly. Named volumes sit under /var/lib/docker/volumes/. Databases need a dump first, because copying live database files gives inconsistent snapshots.

This guide works with any restic REST server.
Ours is zero-knowledge and ready in a minute: Starter $3/mo for 250 GB, or $30 a year with yearly billing. 30-day money-back on every paid plan.
Choose Starter, 250 GB

Backing up bind mounts (simplest case)

Bind mounts such as ./data:/app/data are plain host paths, so back up the host path directly:

Shell
restic backup /opt/appdata /opt/compose /etc \
  --tag docker \
  --exclude="*/logs" \
  --exclude="*/tmp"

Running Home Assistant in a container? Our guide to backing up Home Assistant offsite with restic covers the config directory and the pre-backup snapshot.

Backing up named volumes

Named volumes live under /var/lib/docker/volumes/ and need root to read. Back up the whole directory and exclude build caches:

Shell
# List your volumes
docker volume ls

# Back up all named volumes
sudo restic backup /var/lib/docker/volumes/ \
  --tag docker-volumes \
  --exclude="*/buildkit"

On Unraid, containers keep their data in appdata; backing up Unraid appdata with Restic covers the Unraid paths and scheduling.

Database pre-backup hook

For Postgres or MySQL, dump to a file before the restic run. A dump restores cleanly; live database files often do not.

Shell
#!/bin/bash
set -euo pipefail
source /etc/restic/env

# Dump Postgres
docker exec postgres pg_dumpall -U postgres > /tmp/pg_dump_$(date +%Y%m%d).sql

# Dump MySQL/MariaDB
docker exec mariadb mysqldump -u root -p"$MYSQL_ROOT_PASSWORD" --all-databases > /tmp/mysql_dump_$(date +%Y%m%d).sql

# Now back up everything including the dumps
restic backup /opt/appdata /tmp/pg_dump*.sql /tmp/mysql_dump*.sql \
  --tag docker

# Clean up dumps
rm -f /tmp/pg_dump_*.sql /tmp/mysql_dump_*.sql

Run retention with your cleanup key from one trusted machine, never from the hosts you back up; see retention on ServerCrate vaults.

Full docker-compose setup

To run restic itself in a container, this compose snippet mounts your data read-only and runs a nightly backup:

YAML
services:
  restic:
   image: mazzolino/restic:latest
   hostname: docker-host
   restart: unless-stopped
   environment:
   RUN_ON_STARTUP: "true"
   BACKUP_CRON: "0 30 2 * * *"
   RESTIC_REPOSITORY: rest:https://vaultuser:YOUR_TOKEN@a1b2c3d4.vault.servercrate.net/
   RESTIC_PASSWORD_FILE: /run/secrets/restic-pass
   RESTIC_BACKUP_SOURCES: /data
   volumes:
   - /opt/appdata:/data:ro
   - /root/.restic-pass:/run/secrets/restic-pass:ro

Setting up the vault target

Set your vault connection string as RESTIC_REPOSITORY. It is hosted Restic over HTTPS: no SSH or SFTP server, no egress fees.

Scheduling Docker backups automatically

For host-level backups, use a systemd timer; the systemd timer guide has the units. In a container, the mazzolino/restic image schedules with the BACKUP_CRON variable in standard cron syntax.

Dumps and backup must run in order: natural in a host script, and in a container use an entrypoint that dumps, then backs up.

What to skip in a Docker backup

Large, fast-changing, cheap-to-recreate artifacts do not belong in an offsite backup:

  • /var/lib/docker/overlay2:Image layers, recreated by pulling. Can be hundreds of GB.
  • Build caches:Buildkit caches in /var/lib/docker/buildkit.
  • Log files:Exclude unless audit retention requires them.
  • Temporary files:/tmp, /run and runtime state inside volumes.

Focus on what is painful to regenerate: database contents, uploaded files, config outside version control, and TLS certificates.

Verifying Docker volume restores

After a restore, confirm the app starts; for databases, load the dump into a test container and check row counts. See the restic restore guide.

Next step: your first offsite backup

On a Linux server, our installer does the setup in one line: it installs restic, creates your encryption password on your machine, takes a first snapshot and schedules a daily backup. The Vault page in your portal shows this line with your vault filled in.

Linux, one-line installer
curl -fsSL https://servercrate.net/install.sh | sudo sh -s -- --repo "rest:https://vaultuser:YOUR_TOKEN@a1b2c3d4.vault.servercrate.net/"

Add --dry-run to see what it would do without changing anything. On macOS or Windows, or to do it by hand, follow the setup guide.

Starter fits most single servers and small homelabs.
Starter $3/mo for 250 GB, or $30 a year with yearly billing. 30-day money-back on every paid plan. Or start with 10 GB free, no card.
Choose Starter, 250 GB

Restic Docker backup FAQ

Use env_file pointing to /etc/restic/secrets.env with RESTIC_PASSWORD and RESTIC_REPOSITORY set inside, mounted read-only, mode 0600, owned by root. Never use environment: in compose, which leaks via docker inspect.
The Restic container runs as root inside but the bind-mounted /data is owned by your host user. Either chown the host directory to match the container's UID or run Restic with user: in compose set to your host UID:GID.
Use a systemd timer on the host that runs docker compose run --rm restic backup. Scheduling stays outside the container, you get systemd logging and failure handling, and you can upgrade Restic without touching the schedule.
Yes, but use a separate service with a different command. Prune locks the repository for minutes to hours; you don't want a backup attempt blocked behind prune. Schedule prune weekly via a separate systemd timer.
Set logging.driver: journald in compose so logs go to systemd-journald on the host. Then grep with journalctl -u docker-restic or forward to Loki. The default json-file driver fills the disk over time.

Keep going

Start backing up Docker offsite today.

Private vault. Flat pricing. No egress fees when you restore.

Need more than 10 GB? Starter is 250 GB for $30/yr, and every plan keeps the same vault and key when you move up.

Cancel anytime. 10 GB free tier never expires. No egress fees.