Restic is one of the cleanest backup tools for VPS environments—encrypted by default, deduplication built in, supports dozens of backends. But automated backups fail in ways that won't wake you up at 3 AM. The snapshot runs, the cron log says "success," and six months later you discover the repository is corrupted or your retention policy never ran.
I've debugged enough support tickets to know the pattern. Below are the nine mistakes that break Restic automation, from silent disk-full errors to missing pre-flight checks. Each section shows what goes wrong and the correct setup.
1. No error handling in the cron job
The default cron behavior swallows errors. Your backup script exits with code 1, the snapshot fails, and cron sends an email to root that nobody reads.
Wrong approach:
0 2 * * * restic backup /var/www
Correct approach—capture exit codes and send alerts:
#!/bin/bash
set -euo pipefail
export RESTIC_REPOSITORY="s3:s3.amazonaws.com/my-backup"
export RESTIC_PASSWORD_FILE="/root/.restic-pass"
restic backup /var/www /etc /home --exclude-file=/root/restic-exclude.txt
if [ $? -ne 0 ]; then
echo "Restic backup failed at $(date)" | mail -s "Backup alert" [email protected]
exit 1
fi
Set MAILTO in your crontab or pipe failures to a monitoring service. I prefer a simple curl to a healthcheck endpoint that expects a ping every 24 hours; silence triggers an alert.
2. Repository never gets pruned
Restic deduplicates chunks but doesn't delete them automatically when you remove snapshots. Over months the repo balloons with orphaned data. Backup times stretch from minutes to hours.
Forget policies delete old snapshots but don't reclaim space:
restic forget --keep-daily 7 --keep-weekly 4
You must run prune separately:
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
Or schedule it weekly in a separate cron job. Prune is I/O-heavy; run it during low-traffic windows. Check the output—if it reclaims gigabytes every time, your retention window might be too aggressive.
3. Forget policy runs but never actually forgets
A subtle one. The forget command only affects snapshots with matching hostnames and paths. If your VPS hostname changed or you restored from a different machine, old snapshots survive indefinitely because the filter doesn't match.
List all snapshots:
restic snapshots
If you see multiple hostnames, target them explicitly:
restic forget --host old-hostname --keep-last 1 --prune
Or forget all snapshots for a specific path:
restic forget --path /var/www --keep-daily 7 --prune
Document your retention logic in the script. Future you will thank past you.
4. Backing up live databases without a dump
Pointing Restic at /var/lib/mysql while MariaDB is running captures inconsistent files. The snapshot completes but restore fails with corruption.
Wrong:
restic backup /var/lib/mysql
Correct—dump first, then back up the SQL file:
#!/bin/bash
mysqldump --all-databases --single-transaction > /backup/mysql-dump.sql
restic backup /backup/mysql-dump.sql /var/www /etc
rm /backup/mysql-dump.sql
For PostgreSQL use pg_dumpall. For large databases consider streaming the dump directly into Restic via stdin:
mysqldump --all-databases | restic backup --stdin --stdin-filename mysql-dump.sql
This skips writing the dump to disk. Saves time and space.
5. No backup verification
You assume the snapshot is good because Restic didn't error. Then you try to restore and discover the repository is missing pack files or the backend silently truncated data.
Run check monthly:
restic check --read-data-subset=5%
The --read-data-subset flag samples 5% of pack files to catch bit rot without scanning terabytes. Schedule this in a separate cron job and alert on failures.
Better yet, test actual restores. Pick a random snapshot quarterly and restore it to a scratch directory:
restic restore latest --target /tmp/restore-test --path /etc/nginx
Compare the files. If they match production, delete the test.
6. Storing the password insecurely
Hardcoding RESTIC_PASSWORD in the cron script or a world-readable config is a fast way to leak your entire backup history.
Wrong:
export RESTIC_PASSWORD="mypassword123"
Correct—use a password file with restrictive permissions:
echo "your-strong-password" > /root/.restic-pass
chmod 600 /root/.restic-pass
Then reference it:
export RESTIC_PASSWORD_FILE="/root/.restic-pass"
For S3 or cloud backends, store credentials in environment files or use IAM roles. Never commit passwords to version control.
7. Restic fills the root partition
The local cache directory (~/.cache/restic) grows over time. On small VPS instances with a single root partition, this can exhaust disk space and break all backups.
Check cache size:
du -sh ~/.cache/restic
Move it to a larger partition or set a size limit:
export RESTIC_CACHE_DIR="/mnt/backup-cache"
Or disable caching entirely for remote repos (trades speed for reliability):
restic backup /var/www --no-cache
Monitor / usage in your server monitoring. A 90% threshold should wake someone up.
8. Exclude file is ignored or missing
You add /var/log and node_modules to an exclude file but Restic still backs them up. Usually this happens because the exclude file path is wrong or the patterns don't match.
Test your excludes:
restic backup /var/www --exclude-file=/root/restic-exclude.txt --dry-run -vv
The -vv flag shows exactly what gets included. Patterns are matched against full paths, so node_modules won't catch /var/www/app/node_modules—use **/node_modules or /var/www/**/node_modules.
Example exclude file:
/var/log
/tmp
/var/cache
**/.git
**/node_modules
**/__pycache__
*.log
*.tmp
Absolute paths and globs both work. Document why each line exists.
9. Backup bandwidth crushes the VPS
Restic uploads chunks during the backup, and a full backup of 50 GB over a 100 Mbps uplink can saturate the connection for hours. Your web traffic suffers.
Limit bandwidth:
restic backup /var/www --limit-upload 5120
The value is in KiB/s, so 5120 = 5 MB/s. Adjust based on your uplink and traffic patterns. Run backups during off-peak hours if possible.
For the initial snapshot, consider running it from a local machine or a separate backup VPS that pulls data via rsync, then uploads to the repository. Subsequent incremental backups are much smaller.
What about retention policy conflicts?
If you run multiple forget policies (daily in one script, weekly in another), the last one wins. Restic doesn't merge them.
Consolidate all retention logic into a single script and run it once per day:
restic forget \
--keep-hourly 24 \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 12 \
--keep-yearly 3 \
--prune
This keeps 24 hourly snapshots (for sub-daily backups), 7 daily, 4 weekly, 12 monthly, and 3 yearly. Adjust to your RPO and available storage.
So what if everything looks fine but restores are slow?
Restic rebuild-index can help. Over time the index fragments, especially after many forget/prune cycles.
restic rebuild-index
This rewrites the index files and can speed up restore and mount operations. Run it quarterly or whenever you notice performance degradation.
Monitoring and alerts
Set up at least three checks:
- Backup completion: Use a dead-man switch service (like healthchecks.io or a self-hosted equivalent). The script curls an endpoint on success; if 25 hours pass without a ping, you get alerted.
- Snapshot count: Weekly, assert that the number of snapshots matches your retention policy. If you expect 7 daily snapshots but find 3, something is breaking.
- Repository size: Track growth over time. A sudden jump suggests the exclude file broke or someone added a large dataset.
Log all operations to a dedicated file and rotate it:
restic backup /var/www 2>&1 | tee -a /var/log/restic-backup.log
Grep for "error" and "fatal" in your monitoring.
Your backup checklist
Before you trust an automated Restic setup:
- Test a full restore to a scratch directory and compare files
- Confirm that
forget --pruneruns and reclaims space - Verify the exclude file by running a dry-run with
-vv - Set up a dead-man alert that fires if backups don't run
- Document the retention policy and why you chose those intervals
- Check repository health monthly with
restic check - Store passwords and credentials securely (mode 600, password files, IAM roles)
- Limit upload bandwidth if your VPS is on a shared or metered connection
- Run database dumps before backing up live database directories
Backups that aren't tested aren't backups. Schedule a restore drill every quarter and make someone document the process. That's when you'll find the missing step or the hardcoded path that only worked on the old server.
Most failures are silent. Restic won't email you when prune skips gigabytes of orphaned data or when your retention policy doesn't match the hostname. Build verification into the automation—don't wait for the disaster to discover the backup was hollow.
