Backups on Linux: tar, rsync and snapshots
You set up full, incremental and differential backups with tar and rsync, take consistent backups with LVM snapshots, automate the work and run regular restore tests.
Level 201 · 16 lessons · 15 practice labs
Lessons
Kinds of backup
- Full, incremental and differential backups
- Incremental backups with tar: --listed-incremental
- Local backups with rsync and the delete options
- A time machine with rsync --link-dest
- Short task: set up a seven-daily, four-weekly rotation
Consistency
- Open files and the consistency problem
- Point-in-time backups with LVM snapshots
- Hooking database dumps into the backup
- Short task: take a consistent backup of a running application
Automation
- A backup script and a systemd timer
- Monitoring backup success and alerting
- Backup permissions and encryption
- Short task: make failed backups show up in the morning report
Restoring
- Writing a restore procedure
- Restoring ownership, ACLs and attributes
- Capstone: automated, verified backups and a restore drill for a file server
Practice labs
- Compare the size of full and incremental backups: Take a full and then an incremental backup of one directory and report the size and file count of both archives.
- Set up weekly full and daily incremental with tar: Using a snapshot file take one full and three incremental backups, then restore the state of day three in order.
- Create daily hard-linked snapshots: With rsync build a scheme that shows each day in its own folder while sharing unchanged files through hard links, and measure real disk use.
- Show the inconsistency of a backup taken during writes: Archive a data file while it is being written, restore it and show that the integrity check fails.
- Dump the database first, then back it up: Add a database dump step to the backup script, make the backup fail if the dump fails, and try a restore from the dump.
- Take a consistent backup from an LVM snapshot: Create a snapshot of a running service's volume, back up from it, remove the snapshot and combine the steps in a failure-safe script.
- Run the backup from a systemd timer: Write a service and timer unit for the backup script and show a missed run is caught up at boot.
- Set up an alert that exposes a failed backup: Find a backup that has been failing silently for days because the target disk is full and add a check that logs a clear record on failure.
- Apply daily, weekly and monthly retention: Write a pruning script that keeps seven daily, four weekly and six monthly backups and verify what survives on a sample archive set.
- Send the backup to a second server over SSH: Send the daily archive to the backup server using rsync with key authentication and compare the hashes on both sides.
- Restrict the backup key to one command: Restrict the key on the backup server so it only permits receiving rsync data and show that no shell can be opened.
- Encrypt the outgoing backup and keep the key safe: Encrypt the archive with a public key before sending, show the private key is not on the backup server and test a restore.
- Restore a backup with ownership and permissions: Restore a web root from backup and verify ownership, permissions and ACLs match the original state.
- Return a file to its state three days ago: From an incremental chain find the version of one config file from three days ago and show its difference from the live one.
- Run a timed restore drill: Restore files and database from backup onto an empty server, bring the service up and compare the elapsed time with the target.
About this course
You set up full, incremental and differential backups with tar and rsync, take consistent backups with LVM snapshots, automate the work and run regular restore tests.
What you will learn
- Kinds of backup
- Consistency
- Automation
- Restoring
Prerequisites
Finishing the level 101 courses of the same path, or knowing those topics, is enough.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at level 201; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.