We ❤️ Open Source
A community education resource
How to build automated Linux backups that don’t silently fail
A hands-on tutorial for rsync backups with systemd automation and Healthchecks.io monitoring.
Backup scripts that silently fail are worse than no backups at all. In this video from Learn Linux TV, you’ll learn how to build a production-ready backup system using rsync, systemd timers, and failure monitoring.
Jay walks through creating a Bash script that backs up files with rsync while retaining previous versions in case you need to restore something. The script uses archive mode to preserve metadata, --delete to sync deletions, and --backup-dir to move replaced files into dated directories instead of losing them forever.
The tutorial covers critical production details like mounting NFS shares for remote backups, using --dry-run to test safely before running for real, and implementing a mount point check that prevents the script from writing backups to the local filesystem if your network share drops.
After building the script, Jay creates a systemd service and timer to run backups automatically at midnight. He explains why you enable the timer but leave the service disabled (the timer handles starting it), and demonstrates the Persistent=true option that ensures missed backups run when the system comes back online.
The final piece addresses silent failures. Jay integrates Healthchecks.io by adding a curl call that pings the service only when rsync exits successfully. If the backup doesn’t run or fails, you get an email alert instead of discovering the problem weeks later when you actually need those backups.
Key takeaways
- Test with dry-run before going live – The
--dry-runflag shows exactly whatrsyncwould do without actually copying files, preventing costly mistakes during initial setup. - Retain replaced files in dated directories – Using
--backup-dirwith a timestamp variable preserves old versions whenever files change, giving you version history without manual snapshots. - Monitor for silent failures – Integrating monitoring services like Healthchecks.io ensures you know immediately if backups stop working instead of discovering it when disaster strikes.
This hands-on lab delivers a genuinely useful backup system you can run in production. Jay’s approach combines rsync, systemd automation, and failure monitoring into a complete solution that actually works.
More from Learn Linux TV
- youtube.com/learnlinuxtv
- Linux tips | Linux how-to’s | Linux installation guides
- Why Linux experts are ditching Man pages for this simple tool
- 5 practical tips for learning Linux tools
- 10 tips to learn Linux easier and faster
The opinions expressed on this website are those of each author, not of the author's employer or All Things Open/We Love Open Source.