Practical guides · Backup & recovery
Running Restic well: backup strategy, retention and monitoring
Restic has been running for months. Then the repository starts filling up, the off-site copy falls behind, and nobody can quite remember the last successful restore. Where do you start?

A deletion spotted on Monday might need a version from Friday. After a server failure, you need a recent copy you can get running quickly. Decide how old that copy can be and use that limit to schedule backups and off-site copies. Give retention and pruning their own schedule. Monitor the age of the data in both repositories and practise getting the service running again.
How much work can you afford to lose?
Imagine a small document service. How much work could the team redo after an outage? How long can they do without the service? The first answer tells you how old the latest usable copy can be when an outage happens (RPO). The second sets the time you have to restore service (RTO). Include finding credentials, preparing a replacement host and checking the application.
The database, attachments and configuration belong together. If the service runs in containers, record its image digest and configuration revision too. A PostgreSQL dump can import successfully even when an attachment it refers to is missing. Capture the database and files at a consistent point, for example by briefly pausing writes. Record that point in time so you can tell how much work a restore would lose.
Use 3-2-1 to decide where to keep the data. Have three copies including the working data, use two types of storage media and keep one copy off-site. A separate backup system on-site makes it quicker to recover large files. The off-site copy needs to be reachable when the first site goes down. Joint CISA guidance on the 3-2-1 rule.
Give the copies separate access controls, too. With separate credentials for each repository, a single stolen login can do less damage. If the source host is gone, the team still needs the repository password and the credentials for its storage. Keep those somewhere the team can reach without the source host, and try that access path during the next restore.
Give backups a rhythm and maintenance a window
An hourly backup could suit a team that can redo several hours of work. If an hour is the most you can lose, an hourly start gives you too little room. Capturing and copying the data take time. Choose an interval that leaves room for that work and another attempt if the first one fails.
On Linux, a Type=oneshot systemd service can run the backup under a dedicated account, report the exit status and send output to the journal. Give the account read access to the data it needs. Point RESTIC_PASSWORD_FILE at a protected file so the backup can run unattended. Restic options for unattended jobs.
This excerpt goes in the [Timer] section of an existing timer for the backup service. A small random delay spreads out the start times when several machines use the same storage.
[Timer]
OnCalendar=hourly
Persistent=true
RandomizedDelaySec=5m
If the timer missed a scheduled run while inactive, Persistent=true triggers one run when it next starts. That captures the current data. Any gap in the history remains. The timer also leaves an already running backup service alone. Coordinate separate copy and maintenance services so they have time to access the repository. systemd.timer.
More detail in recent history, fewer points further back
In the first week after a bad change, it helps to have several versions from the same day. For mistakes that only surface at month-end, a few points further apart will often do. For the document service, you might keep all snapshots for seven days, plus 30 daily, 12 weekly and 12 monthly points.
The dry run below applies to the repository you have already selected for the first copy. files01 and documents are the document service’s host and tag. Replace them with the values in your snapshot list. --dry-run shows which snapshots would stay and which would be removed.
restic forget --dry-run --host files01 --tag documents \
--group-by host,paths --keep-within 7d --keep-daily 30 \
--keep-weekly 12 --keep-monthly 12
Restic applies the policy to each group of snapshots with the same host and backup paths. A dated file inside the backed-up directory is fine. If the dated directory is itself the backup path, you get a new group every run. The policy may then keep far more snapshots than you expected. A stable path and tag make the dry-run output easier to review.
The seven days count back from the latest snapshot in each group. The daily, weekly and monthly counts cover periods that contain snapshots. A snapshot can satisfy several rules. In our dry run with a short history, Restic also kept the oldest point and labelled it oldest daily snapshot. Read the dates and reasons in the output to see which versions you would keep. Restic retention rules.
forget removes snapshot entries. prune reclaims data that none of the remaining snapshots use. With hourly backups, you might apply the reviewed retention policy once a day and give pruning a window of its own once a week. Pruning locks the repository against backups. Watch how long it takes and how fast the repository grows, so you can leave room for the next backup.
Leave some capacity free for maintenance. During pruning, Restic can repack data it still needs before removing the old packs. --max-repack-size limits the amount of data selected for repacking. A tighter limit may reclaim less space in that run. Restic pruning options and space requirements.
Does your backup plan fit the way you work?
We can review your retention, monitoring and recovery from the second copy with you.
Give the off-site copy its own rules
After a complete backup, use restic copy to transfer its snapshot to a second, separately encrypted repository. Pass the ID of the complete snapshot when you copy it. That way, another backup can finish in the meantime without changing which snapshot gets copied. Record the copy’s result separately. The local job can succeed while the transfer fails. Copying snapshots between Restic repositories.
The backup account can write to the off-site destination through a Restic server in append-only mode. That access can add backup data but cannot overwrite or delete the existing data. Reclaiming space takes a separate, protected maintenance account. Keep its credentials away from the backup service and the monitoring process. Watch the off-site storage quota as well. New data can still fill it.
A compromised host could still add unusable snapshots. If maintenance keeps only the newest one in each week, a bad snapshot can displace a good one. Give the second copy its own policy. A sufficiently long --keep-within window keeps all points within it and gives you time to investigate suspicious snapshots. If the last verified copy has already fallen outside that window, preserve it before removing snapshots. Restic retention with append-only storage.
What would you want the next alert to tell you?
A snapshot appears at ten this morning. If it contains yesterday’s database dump, yesterday is still the point you can recover. In a test with an old export, the full repository check passed and the data-age check raised the alert. For each copy, record the data’s capture time alongside the snapshot ID. Track the latest attempt’s result separately.
restic backup can also leave a snapshot behind after an incomplete run. Exit code 3 means Restic could not read some of the source data. Treat that run as a failure and keep the timestamp of the last complete backup. Do the same if the fresh database export fails before the backup gets started. Restic exit codes.
| What to watch | When an alert helps |
|---|---|
| Latest run | A backup, copy or maintenance job fails. Include the job, repository and exit code. |
| Data age for each copy | The last complete recovery point is getting close to its age limit. Alert while there is still time to run another backup. |
| Duration and capacity | Jobs are taking nearly as long as the backup interval, or there will soon be too little space for new data and maintenance. |
| Repository checks | The last check found an error or the next check is overdue. Record whether the check read the stored data. |
| Recovery exercises | Another test is overdue, an application check fails or recovery takes longer than planned. |
| Missing reports | A report is missing, stale or unreadable. Report the state as unknown and assign someone to investigate. |
After pruning, a restic check is a good way to check the structure of the repository. For a scheduled test of the stored data itself, select the repository you intend to check and run the extended check.
restic check --read-data
With --read-data, Restic reads every data pack and verifies its contents. For a large remote repository, budget for the time and data transfer. Give it a window of its own. If you check subsets, record which portion each run covered. Checking a Restic repository.
For a recovery exercise, pick a known snapshot and bring the service up in a separate environment. For the document service, a simple test is to open a known document through the application and create a new entry. Try recovering with just the off-site copy on a regular basis. Note the recovery point, how long it took from retrieving the credentials to the application test, and which steps someone had to do by hand.
In Icinga, give each repository its own data-age check. The team can see straight away whether the off-site copy is lagging or the first backup has already stopped. Test that a missing report raises an alert and that the message after the next successful run makes clear what recovered. Check the notification path in Icinga Director.
Eight questions to ask before you need the backup
- Have you captured the data, configuration and everything the service needs to start?
- Do the database and files agree, and do you know the point in time they represent?
- Does the backup interval leave time to transfer data and retry a failed run?
- Can you reach the second copy if the first site is down?
- Have you reviewed the retention dry run and left enough space for pruning?
- Can the team get the keys and storage credentials during an outage while keeping off-site deletion rights away from the backup service?
- Does monitoring flag old data and missing reports for each copy?
- Has someone started the service from the second copy, checked that it works and recorded the recovery time?