FL1GHT5 Lab • Linux & Servers

Back Up Docker Volumes with Restic

Who This Is For

Intermediate.

Think of it like photocopying the actual documents before shredding the originals, not just the empty folder they were sitting in. Copy the wrong thing and the backup is worthless the day you need it.

What You'll Build

A scheduled encrypted backup of at least one Docker application, with a documented restore test.

Prerequisites

Compose Files Are Not Backups

A compose.yaml recreates the service definition, it says nothing about the data inside volumes and bind mounts, which is what actually needs backing up.

Initialize a Repository

$export RESTIC_REPOSITORY=/mnt/backup-nas/restic-repo
$export RESTIC_PASSWORD=your-strong-password
$restic init

Back Up a Stack

$restic backup /opt/stacks/uptime-kuma

Exclude Disposable Files

$restic backup /opt/stacks/nextcloud --exclude="*.tmp" --exclude="cache/"

Handle Database Consistency

Briefly stop the service, or use the application's own export/dump tool, so you're not backing up a database mid-write.

$docker compose stop
$restic backup ./data
$docker compose start

Schedule It

A systemd timer or cron job running the backup command daily is enough to start.

Retention and Pruning

$restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune

Restore Test

$restic restore latest --target /tmp/restore-test

Security & Backup Notes

Troubleshooting

Lab Finish Line

Scheduled encrypted backup of at least one Docker application and a documented restore test.

What to Build Next

Planning a business implementation?

Explore our infrastructure and systems services.

View services