Lion Cipher Lab
Automate encrypted backups with cron and restic
- Cyber / Security Engineer
- Intermediate
- ~45 min
- Free · no account required
Why it matters
The restic lab gave you encrypted, versioned backups -- but only when you remembered to type the command. That is the quiet failure mode of every hand-run backup: the week you are busiest, or sick, or travelling, is the week you skip it, and that is exactly when a laptop gets stolen or a drive dies. A backup you have to remember is a backup you will eventually forget. Automating it with cron removes the one unreliable part of the system: you. But automation swaps one risk for a sneakier one. When a human ran the backup, a human saw it fail. Hand the job to a scheduler and, unless you build in…
What you'll learn
- automating restic backups on a schedule with cron
- writing a small, safe backup shell script
- storing a repository password in a permission-locked file instead of in the script
- reading exit codes to tell success from silent failure
- logging backup runs and confirming the job actually fired
- the discipline of testing restores on a real schedule
Steps in this lab
- Why automate -- the backup you have to remember is the one you forget
- The words you need: cron, crontab, script, exit code, prune
- Store the repository password safely -- in a locked file, never in the script
- Write the backup script -- backup, then forget --prune
- Add logging and a success/failure check
- Schedule it with cron
- The part that matters most: test your restore and confirm it actually ran
- The system that runs itself -- and proves it