Backups That Tell You the Truth
- The night nothing went wrong
- Why the folder was still there
- The one idea
- What this book is
- Who this book is for
- What you will be able to do
- The one rule
- How to use this book
- About the language in this book
- A note on honesty
- Where to start
- Part 1 — Start here
Run it, and know whether it worked
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. A command answers twice
- Step 2. Make it fail on purpose
- Step 3. The number is replaced every time
- Step 4. Your first script
- Step 5. Say no yourself
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
One word or two
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. A variable holds a piece of text
- Step 2. Watch the shell chop it
- Step 3. What the chopping does to a real check
- Step 4. Three answers, three meanings
- Step 5. Why nobody caught it
- Step 6. Your first tool
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Ask before you act
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1.
ifruns a command - Step 2.
[is a command with a one-character name - Step 3. Give
check.shboth branches - Step 4. Your first test file
- Step 5. Two details doing real work
- Step 6. Build the print-shop bug
- Step 7. The form this book’s tool uses
- Step 8. The fix reads the words
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Stop when something is wrong
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. A failed line does not stop the script
- Step 2.
set -estops it - Step 3. The failure
set -emust ignore - Step 4. Or else —
||and&& - Step 5.
set -uand the name you mistyped - Step 6.
pipefailand the failure at the front of the queue - Step 7. The header goes in — and what it does not fix
- Step 8. What the header cannot see, your tests can
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Name the check
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. A block of commands with a name
- Step 2. A function answers like a command
- Step 3. The name you did not mean to share
- Step 4.
localkeeps the name inside - Step 5.
die— the guards’ refusal, built - Step 6.
returnhands the answer back;exitends everything - Step 7. Why you run scripts, and stop sourcing them
- Step 8. The rewrite your tests did not notice
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Values you can trust
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. Set, and holding nothing
- Step 2. Demand a real value at the door
- Step 3. The colon is what catches the blank
- Step 4. The other honest answer — a default
- Step 5. Refuse in your own words
- Step 6. Capture an answer
- Step 7. The captures that lie
- Step 8. The assertion you were told to leave out
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Do it to each of them
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. A list is not a string
- Step 2. The ghost files
- Step 3. The loop that ran zero times
- Step 4. The guard that inspects the wrong thing
- Step 5. Count before you loop
- Step 6. Every folder, one run, every fault
- Step 7. The recipe where the suite goes red
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Prove a check can fail
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. The two names the guard compares
- Step 2. The line that lets a file be read
- Step 3. Testing a script’s insides
- Step 4. Break it on purpose
- Step 5. Assert the message, and the pair
- Step 6. The names the harness owns
- Step 7. Reading a suite you did not write
- Step 8. Why a suite has more than two tests
- Step 9. What this harness does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
- Part 2 — The guards
Load the settings, and refuse a bad one
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. A file that only sets variables
- Step 2. The hole arrives at load time
- Step 3. Demand each setting where it enters
- Step 4. A list is present before it is long
- Step 5. The gate, assembled — and the file it must not trust
- Step 6. The name that meant two files
- Step 7. Prove it, in both directions
- Step 8. What this gate does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Prove the drive is really there
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. The empty husk, built to order
- Step 2. Two questions, read apart
- Step 3. The guard, and what it refuses
- Step 4. What this check does not prove
- Step 5. Prove it — the sabotage suite
- Step 6. The measurement, in both directions
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Keep the backup inside the drive
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. A path is a name, not a place
- Step 2. The obvious check, predicted and run
- Step 3. The check that works
- Step 4. A destination that does not exist yet
- Step 5. Prove it
- Step 6. The measurement, and the break it cannot measure
- Step 7. What this check does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Every source must still be there
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. A dropped share, built to order
- Step 2. The gate that stops too early
- Step 3. Ask every folder, then answer once
- Step 4. Two branches, each right for its own reason
- Step 5. The caller decides
- Step 6. What this check does not prove
- Step 7. Prove it, in both directions
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Make sure there is room
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1 The check you would write first
- Step 2 The floor with a unit typed into it
- Step 3 Validate the number where it enters
- Step 4 Two failures, two numbers
- Step 5 What the suite must not trust
- Step 6 The measurement, in both directions
- Step 7 What this check does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Do not let two runs overlap
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1 Two runs, one number
- Step 2 The first fix: a marker file
- Step 3 The crash that jams it shut
- Step 4 The gate: let the kernel referee
- Step 5 The referee at work
- Step 6 The crash, revisited
- Step 7 What the suite must prove
- Step 8 Break it on purpose, in both directions
- Step 9 What this gate does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Clean up, and say why you died
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1 The script that dies saying nothing
- Step 2 The cleanup trap: tidy on every way out
- Step 3 The report trap: the death explains itself
- Step 4 What the report trap deliberately ignores
- Step 5 Where the traps live, and the suite that vanished
- Step 6 The death no trap can answer
- Step 7 What the suite must prove
- Step 8 The measurement, in both directions
- Step 9 What this pair does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
The name must resolve, the port must answer
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1 The probe with no clock
- Step 2 The wait that is not a failure
- Step 3 Two questions, two gates
- Step 4 Why
getent, and not the tool everyone reaches for - Step 5 Two seconds, on purpose
- Step 6 The hostname that tries to be a command
- Step 7 What the suite must prove
- Step 8 The measurement, in both directions
- Step 9 What this pair does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
Trust the folder, not just the file
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. The check you would write
- Step 2. Watch it accept a file it never saw arrive
- Step 3. Why the folder decides
- Step 4. The gate
- Step 5. The suite
- Step 6. The measurement, in both directions
- Step 7. What this gate does not prove
- Common mistakes
- Check yourself
- Lab
- Summary
Never run the destructive form by accident
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. The check you would write
- Step 2. The three commands it cannot tell apart
- Step 3. What an authorisation has to name
- Step 4. The gate
- Step 5. The suite
- Step 6. The measurement, in both directions
- Step 7. What this gate does not prove
- Common mistakes
- Check yourself
- Lab
- Summary
Say what you excluded
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. The check you would write
- Step 2. Watch three lists, and count what arrives
- Step 3. First match wins, and what that costs
- Step 4. The gate
- Step 5. The suite
- Step 6. The measurement, in both directions
- Step 7. What this gate does not prove
- Common mistakes
- Check yourself
- Lab
- Summary
- Part 3 — The test suite
Run them all
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. One suite, one report
- Step 2. A second suite, and the problem
- Step 3. The runner, typed whole
- Step 4. Run them all
- Step 5. A suite that cannot fail
- Step 6. A suite whose tests never ran
- Step 7. Break something, and read the red
- Step 8. The toolkit’s own battery
- Step 9. What this runner does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
- Part 4 — Build it
Build it
- Learning objectives
- Key terms
- Why this matters
- The lesson
- Step 1. Two mount points your machine already has
- Step 2. The frame
- Step 3. Twelve files, sourced once
- Step 4. main opens: traps, usage, the config’s folder, the config
- Step 5. The config, and its mode
- Step 6. The drive folder, and a server that is not there
- Step 7. The rules, checked before rsync sees them
- Step 8. The copy, rehearsed
- Step 9. The first real run, then the second
- Step 10. The deleting form, refused and then authorised
- Step 11. Two runs, one lock
- Step 12. The report when something nobody watched fails
- Step 13. The wrapper cron runs, and the suites
- Step 14. What this build does not prove
- Common mistakes
- Check yourself
- Lab — predict, then run
- Summary
- Part 5 — When it breaks
When it breaks
- How to read this part
- It says success and the drive is empty
- It filled the system disk
- It hangs
- It ran twice
- It refuses, and I think it is wrong
- When none of these fit
Appendix — The library
- The refusal everything shares
- From Prove a check can fail
- From Load the settings, and refuse a bad one
- From Prove the drive is really there
- From Keep the backup inside the drive
- From Every source must still be there
- From Make sure there is room
- From Do not let two runs overlap
- From Clean up, and say why you died
- From The name must resolve, the port must answer
- From Trust the folder, not just the file
- From Never run the destructive form by accident
- From Say what you excluded
- From Run them all
- What this register proves