When the SD card in a homelab Pi fails, the part that has to come back is the Docker stack: its compose files, its named volumes and the databases those volumes hold. A card image holds all of that in one file, which makes it the obvious first choice, and on a server it falls short. The better plan is restic, backing up the compose files, the volumes and fresh database dumps to a USB disk, with a second repository off-site and a restore tested on a schedule.
Is an SD card image enough?
An image copies the whole card, boot partition and all, so a dead card can be replaced in one step. On a Pi, raspiBackup does this for a running system. It makes unattended full or incremental backups without a shutdown, and a restored backup boots immediately. The operating system, Docker and the containers come back together, as they stood on the day of the backup.
A backup that boots at once is worth having after a card dies, but the data that matters on a Docker Pi sits in volumes and databases, and databases need their own handling. SQLite's documentation warns that a database copied as a plain file can be corrupted if the power or the operating system fails during the copy. A dump gives a consistent copy instead.
An image also gives the operating system the same weight as the data. A fresh Raspberry Pi OS install can replace the first, while no download brings back the second. I think raspiBackup earns its place as a quick way back to a booting system. The backup that protects the stack has to be file-level and versioned, and built around database dumps.
What actually has to be copied?
On a Docker Pi, three things cannot be pulled again from the internet: the compose files with their environment files, the named volumes, and the databases inside some of those volumes. Docker keeps each volume in a directory on the host, so that data sits on the Pi's own storage, and Docker itself says volumes are useful for backups, restores and migrations.
The documented method uses a throwaway container. It mounts the volume, writes an archive of it to a folder on the host and then exits, and a restore runs the same idea in reverse. That suits volumes holding config files and app settings. For a volume that holds a live database, the archive is still a plain file copy, so the database inside needs a dump first.
For PostgreSQL, use pg_dump. Each dump is internally consistent: it is a snapshot of the database as it stood when pg_dump began running. File-level backups are extremely server-version-specific, while a dump can be reloaded into a newer server version. That matters as soon as a compose file pulls a newer Postgres image than the one that wrote the data on the Pi.
Any app that keeps its data in SQLite needs the same care, since a plain copy of its database file carries the corruption risk described above. SQLite's online backup API writes a consistent snapshot to a new file instead. Run the PostgreSQL and SQLite dumps first, into one folder. Then let restic back up that folder together with the compose directory and the volumes.
Which tool: restic, Borg, Kopia or rsync?
The restic project says its cryptography protects both the confidentiality and the integrity of backed-up data. Duplicate data is removed before anything reaches storage, so each new snapshot of volumes that barely changed adds little. A repository can sit in a local directory or on SFTP, restic's own REST Server, S3, Backblaze B2, Azure, Google Cloud Storage or anything rclone can reach.
Restic runs on Linux, macOS and Windows, and on FreeBSD and OpenBSD too, so the Pi is not the only machine that can run a restore. One tool and one set of commands can reach a USB disk on the Pi, a NAS over SFTP and a bucket in the cloud. I pick restic for a Pi server on that basis, ahead of the alternatives below.
Borg removes duplicates through content-defined chunking, encrypts with 256-bit AES and verifies integrity and authenticity with HMAC-SHA256. For remote storage, Borg works over SSH, with any host reachable that way. That suits a second Pi or a NAS with SSH turned on better than a cloud bucket. On Windows, Borg is listed as experimental, through WSL or Cygwin.
Kopia always encrypts: it does not let you create an unencrypted backup. It stores repeated copies of a file once, keeps snapshots as point-in-time records under policies you set, and works with both local and cloud storage. It also ships an official graphical interface, which makes it the one to choose for anyone who would rather click than type commands into a Pi's terminal.
The Raspberry Pi documentation presents rsync as a way to synchronise folders, and on each later run it skips the files it has already transferred. That makes it a sync tool, not a versioned backup repository of the kind restic, Borg and Kopia build. It suits mirroring a large media folder to a NAS, but for compose files, volumes and dumps it belongs beside restic, not in its place.
raspiBackup works at a different level from the other four: it copies the whole running Pi rather than chosen folders, using rsync, tar or dd, and writes to an SD card, a USB drive or an NVMe drive. That makes it a system backup for the board itself, while restic, Borg and Kopia keep deduplicated, encrypted copies of chosen folders in the repositories described above.
Two copies stay at home and the third leaves the house
CISA calls the 3-2-1 rule a trusted guideline: keep three copies of important files, on two different types of storage media such as a hard drive and the cloud, and store one copy off-site, away from the business location. For a home server, that location is the home itself, and on a Pi restic can make both of the backup copies.
The first copy is the live data on the Pi's SD card or SSD. The second is a restic repository on a USB disk on the Pi, or on a NAS reached over SFTP or REST Server, close at hand for restores. The third is a second restic repository in an S3 or Backblaze B2 bucket. The local disk and the bucket are the two media types the rule asks for.
Only the bucket meets the off-site part of the rule, since the USB disk or NAS sits in the same home as the Pi. The same layout works with Kopia, which handles both local and cloud storage. With Borg, the off-site copy has to be a host away from home that the Pi can reach over SSH, because that is how Borg reaches remote repositories.
How do you prove it restores?
"Much more important than backup is restore," the restic project says, and the tool is built so that checking whether all data can be restored is easy. CISA asks for scheduled recovery tests to verify backup integrity. A backup job that reports success proves only that it wrote something. The checks below show whether the data can be read back, at different costs in time or bandwidth.
Start with restic check, which by default does not read the pack files that hold the backed-up data. Adding --read-data reads all of them. On a cloud repository that means downloading every pack file, which may bring higher bandwidth costs. Borg's full test is borg check --verify-data, which the Borg docs call a complete cryptographic verification and very time consuming.
restic check
restic check --read-data
For the cloud repository, the --read-data-subset option checks only a subset of the pack files at a time. Even a full check is not yet the recovery test CISA asks for. Its guidance is to make sure data can be restored "both fully and partially", and on a Pi server those are two different jobs: one brings back files, the other rebuilds the whole stack.
The partial test is a file restore. List the snapshots to find the ID of the latest one, then restore it into a temporary directory with enough space, never over the live data. Next, open the restored compose files, load the PostgreSQL dump into a scratch Postgres container and open the SQLite snapshot. A file that will not open points back to the dump or backup step that made it.
restic snapshots
restic restore --target /tmp/restore-work your-snapshot-ID
The full test matches a dead card, and it runs on a spare Pi or a fresh card while the original Pi stays in service. Install the operating system and Docker, restore the compose directory and the volumes, load the dumps into new database containers and start the stack with the command below. Then open each service and check that its data is there.
docker compose up
Moving from a card image to restic, database dumps and two repositories gives up the simplicity of one file you can write back to a card, and gains copies you can check, restore in part or in full, and bring back after a card fails.
My posts look at how far a Raspberry Pi can go with retro gaming. I test which old consoles run smoothly and which ones struggle. Readers send me questions, and I answer them with plain, practical advice.
17 articles →