Restic is fast, encrypted, and deduplicating. It's one of the cleanest backup tools I've deployed on VPS instances. But nine mistakes will quietly break your automated backups, and you won't know until you need a restore.
This walkthrough assumes a fresh Ubuntu 22.04 or Debian 12 VPS, root or sudo access, and an off-site storage target like S3, Backblaze B2, or another VPS via SFTP. I'll show the full setup, the mistakes that sabotage it, and how to verify your backups actually work.
Install Restic on your VPS
Most distros ship Restic in their repos. Grab the package:
apt update && apt install restic -y
Check the version:
restic version
If you need the latest release, download the binary from GitHub and drop it in /usr/local/bin. Either way works. Now pick your storage backend.
Choose and configure your backup repository
Restic supports local paths, SFTP, S3, B2, Azure, GCS, and more. For a VPS, off-site storage is non-negotiable. Local snapshots won't help if the server dies.
Example: Backblaze B2
Create a B2 bucket, grab the application key, and export credentials:
export B2_ACCOUNT_ID="your_account_id"
export B2_ACCOUNT_KEY="your_application_key"
export RESTIC_REPOSITORY="b2:bucket-name:restic-repo"
export RESTIC_PASSWORD="strong_passphrase_here"
Example: SFTP to a second VPS
export RESTIC_REPOSITORY="sftp:[email protected]:/backups/restic"
export RESTIC_PASSWORD="strong_passphrase_here"
The passphrase encrypts every snapshot. Write it down. Lose it and your backups are gone.
Initialize the repo:
restic init
You'll see confirmation that the repo was created. This step writes the encryption config.
Mistake 1: Forgetting to initialize the repo.
If you skip restic init, every backup attempt will fail with a cryptic error. The automation script won't warn you loudly. It'll just log failures until disk fills or retention breaks.
Run your first manual backup
Before automating anything, verify a snapshot works:
restic backup /etc /var/www /home
Restic scans, deduplicates, and uploads. First run is slow. Subsequent runs are incremental and fast.
List snapshots:
restic snapshots
You should see one snapshot with a timestamp and the paths you backed up.
Mistake 2: Backing up paths that don't exist.
If you include /var/www but your web root is /var/www/html, Restic won't fail. It'll back up an empty or wrong directory. Always verify paths before scripting.
Create the backup script
Put your backup logic in /usr/local/bin/restic-backup.sh:
#!/bin/bash
export B2_ACCOUNT_ID="your_account_id"
export B2_ACCOUNT_KEY="your_application_key"
export RESTIC_REPOSITORY="b2:bucket-name:restic-repo"
export RESTIC_PASSWORD="strong_passphrase_here"
# Backup
restic backup /etc /var/www /home \
--exclude="/var/www/*/cache" \
--exclude="*.log" \
--exclude="/home/*/.cache"
# Forget and prune
restic forget \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 6 \
--prune
# Check integrity once a week (optional, add conditional logic)
# restic check --read-data-subset=5%
Make it executable:
chmod +x /usr/local/bin/restic-backup.sh
Test it:
/usr/local/bin/restic-backup.sh
Mistake 3: Hardcoding credentials in the script without protecting the file.
Anyone with read access can steal your B2 key or SFTP password. Lock it down:
chown root:root /usr/local/bin/restic-backup.sh
chmod 700 /usr/local/bin/restic-backup.sh
Better yet, use environment files or a secrets manager if you run multiple backup jobs.
Mistake 4: Not using --exclude and backing up temp files, caches, and logs.
Without excludes, you'll back up gigabytes of WordPress cache, session files, and rotated logs. Bandwidth and storage costs balloon. Restores take forever. Exclude what doesn't matter.
Automate with systemd timer
Cron works, but systemd timers give you better logging and control. Create /etc/systemd/system/restic-backup.service:
[Unit]
Description=Restic backup service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/restic-backup.sh
Create /etc/systemd/system/restic-backup.timer:
[Unit]
Description=Restic backup timer
[Timer]
OnCalendar=daily
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target
Enable and start the timer:
systemctl daemon-reload
systemctl enable restic-backup.timer
systemctl start restic-backup.timer
Check status:
systemctl list-timers --all | grep restic
You should see the next scheduled run.
Mistake 5: Forgetting Persistent=true in the timer.
If the VPS is down during the scheduled window, the backup won't catch up when it boots. Persistent=true runs missed jobs once the system is back.
Mistake 6: Not checking logs after automation starts.
Even if the timer triggers, the script might fail silently. Check journal logs:
journalctl -u restic-backup.service -n 50
Look for upload errors, auth failures, or network timeouts. Set this up to email you on failure if you want peace of mind.
Configure retention and pruning
The restic forget command in the script tells Restic which snapshots to keep. The --prune flag deletes the actual data blocks that are no longer referenced.
Example retention:
restic forget \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 6 \
--prune
This keeps the last seven daily snapshots, four weekly, and six monthly.
Mistake 7: Running forget without --prune.
Forget marks snapshots for deletion but doesn't free space. Your repository grows forever. Always pair them, or run restic prune separately on a schedule.
Mistake 8: Setting retention too short and losing the snapshot you need.
In support tickets I handled, the usual culprit was keeping only three daily snapshots. A config error introduced on Monday isn't noticed until Wednesday, and by then all good snapshots are gone. A week of daily snapshots plus monthly archives is safer.
Test a restore
Backups you can't restore are useless. Pick a snapshot and restore a file:
restic snapshots
restic restore latest --target /tmp/restore-test --include /etc/hostname
cat /tmp/restore-test/etc/hostname
You should see your hostname. If it matches, your backup chain works.
For a full disaster recovery test, spin up a new VPS, install Restic, configure the same repo credentials, and restore everything:
restic restore latest --target /
That's the real test.
Mistake 9: Never testing a restore.
This is the most common failure. Credentials expire, repo format changes, or a typo in the script means snapshots exist but are incomplete. If you don't restore at least once every few months, you're trusting blind faith.
Monitor repository health
Run restic check periodically to verify integrity:
restic check
This scans metadata and ensures the repo isn't corrupted. For large repos, check a data subset:
restic check --read-data-subset=10%
Add this to your script or run it weekly via a separate timer. Corrupted repos can sit unnoticed until restore day.
What if the backup is too slow?
First backup of a large VPS can take hours. After that, incrementals are fast because Restic only uploads changed blocks.
If daily backups time out:
- Exclude more (logs, cache, temp files)
- Increase
B2_CONNECTIONSor use a faster backend - Run backups during low-traffic hours
- Check network speed between VPS and storage
S3 and B2 throttle uploads on free tiers. Paid plans are faster.
Set up alerting
Your timer runs daily, but how do you know if it fails?
Option one: edit the service file to email on failure. Install mailutils and add:
[Service]
Type=oneshot
ExecStart=/usr/local/bin/restic-backup.sh
OnFailure=status-email@%n.service
Option two: use a cron monitoring service like Healthchecks.io or Cronitor. Add a curl at the end of your script:
curl -fsS --retry 3 https://hc-ping.com/your-uuid
If the ping doesn't arrive, you get an alert.
FAQ
Can I use Restic with cPanel backups?
Yes. Back up /home, /var/cpanel, and /etc separately, then rely on Restic for off-site copies. cPanel's built-in backup is fine for local snapshots but doesn't handle encryption or deduplication.
What happens if I lose the RESTIC_PASSWORD?
Your backups are encrypted and unrecoverable. Store the password in a password manager and write it on paper in a safe place.
How much does B2 storage cost?
Pricing changes, so check Backblaze's site. For small VPS backups under 100GB, costs are typically a few dollars per month.
Can I back up databases with Restic?
Dump the database to a file first, then back up the dump. For MySQL:
mysqldump --all-databases > /backups/mysql-dump.sql
restic backup /backups/mysql-dump.sql
Live database files aren't consistent if backed up while the DB is running.
How do I migrate to a new repository?
Initialize the new repo, then use restic copy to transfer snapshots. This preserves history and deduplication.
Verify these before going live
Before you trust your automated Restic setup:
- Initialize the repo and confirm it with
restic snapshots - Run a full backup manually and check the snapshot list
- Restore at least one file to confirm decrypt works
- Lock down script permissions (chmod 700, root-only)
- Enable the systemd timer and check
journalctlafter the first run - Pair
forgetwith--pruneor schedule prune separately - Set retention long enough that you can recover from multi-day mistakes
- Run
restic checkmonthly - Test a full restore on a throwaway VPS
Those nine mistakes break more backup setups than Restic bugs ever will. Fix them now, and your snapshots will be there when the VPS isn't.
