Backups and redundancy are not the same thing
A mirrored disk does not protect you from a deletion, a malicious encryption or a bad migration. What each mechanism actually protects, and how to build a plan that holds.
It is the most expensive confusion I run into, and it is everywhere: "we're fine, the data is on two disks". Or on three servers. Or "we're with a big provider, they have redundancy".
All of that may well be true. And none of it is a backup.
Two different problems
Redundancy answers a hardware failure. A disk dies, a server goes down, a power supply fails: another copy takes over and the service continues. Redundancy is a property of the present — it keeps you available now.
A backup answers data loss. A file was deleted, a table emptied by a query missing its WHERE clause, a migration went wrong, ransomware encrypted the content. A backup is a property of the past — it lets you return to an earlier state.
The distinction matters for one simple reason: redundancy replicates faithfully. That is exactly what it is asked to do. If you delete a file, redundancy dutifully deletes its copy, on every replica, within milliseconds. If ransomware encrypts your data, redundancy replicates the encrypted data.
Redundancy has no opinion about the quality of what it copies. That is its function, not its flaw.
What redundancy does not protect against
The list is longer than people expect:
- Accidental deletion. The most common case, by a wide margin.
- Application-level corruption. A bug writing wrong data writes it everywhere.
- A failed migration. The schema is changed on every replica simultaneously.
- Ransomware. It encrypts the files; replication propagates the encryption.
- An administrative mistake.
DROP TABLEon the wrong database is replicated faithfully. - Account compromise. Whoever holds rights over the system holds rights over its replicas.
- The provider disappearing. Suspended account, dispute, shutdown: internal redundancy at the provider does nothing for you.
None of these are exotic. The first three are ordinary.
The 3-2-1 rule
It is the starting point, and it is old because it works.
Three copies of the data: the working copy and two backups.
Two different media: two distinct technologies or systems. The aim is to avoid a single failure mode taking both copies.
One copy off-site: on another machine, in another building, with another provider. A fire, a flood or a theft must not be able to take everything.
Two modern requirements are usually, and rightly, added:
One immutable or offline copy, which an attacker who has taken control of the server cannot erase. That is the direct answer to ransomware: if the backup is writable from the compromised machine, it will be encrypted too.
Zero errors on restore, verified — which we come to, and which is the most important point in this article.
Two questions to answer before choosing a solution
Before comparing tools, answer two questions. They determine everything else.
How much data can I afford to lose? That is the recovery point objective. If you back up once a night, the answer is "up to twenty-four hours of work". Is that acceptable? For a personal blog, probably. For an online shop, certainly not.
How long can I afford to be down? That is the recovery time objective. Restoring a hundred-gigabyte database from remote storage takes hours, not minutes. If your answer is "one hour", you have to design for that — and verify it.
These two numbers are not preferences, they are design constraints. They determine frequency, medium and budget.
The particular case of SQLite
Many small projects — this one included — use SQLite. There is a trap worth knowing.
Never copy a .db file while the application is writing to it. You will get an inconsistent copy: a backup that looks valid, is the right size, and turns out to be corrupt the day you try to use it. That is the worst case, because it creates false confidence.
The correct method uses SQLite's online backup mechanism, which produces a consistent snapshot even during writes:
sqlite3 /path/app.db ".backup '/backups/app-$(date +%F).db'"
And remember the database is not everything: files uploaded by users are runtime state too. A restored database referencing missing images is only half restored.
tar czf /backups/uploads-$(date +%F).tar.gz -C /app public/uploads
A backup nobody tests does not exist
This is the heart of the matter, and the part I would most like to stick.
A backup is not a file. It is a verified restore procedure. Until you have restored for real, you do not have a backup: you have an intention, and a file you hope contains what you think it does.
The classic failure modes, all seen in the wild:
- The scheduled job failed silently three months ago. Nobody was monitoring anything beyond its presence in the job list.
- The destination disk has been full for six weeks. The recent files are zero bytes.
- The archive is there, but the encryption passphrase was in the password manager… hosted on the server that was lost.
- The database restores, but the application refuses to start because the schema version no longer matches the deployed code.
- Everything works, but the restore takes eleven hours, and nobody had timed it.
What "testing" means
Not "checking the file exists". Not "checking the size looks about right".
Restore into a separate environment, start the application against it, and verify the data is there. Once a quarter at minimum. Timed. Writing the procedure down while doing it — because on the day of the incident you will not be rested, and you do not want to improvise.
If the procedure is not written anywhere, it exists only in your head, and that is a single point of failure.
Incremental backups, and why deduplication changes everything
Taking a full copy every night is simple and expensive: thirty days of retention for a 10 GB database is 300 GB, most of it identical from one day to the next.
Modern tools split files into blocks, hash each block, and store identical blocks only once. Thirty snapshots of a database that changes little then occupy barely more than one.
Two properties matter more than the space saving:
Each snapshot stays independently restorable. You do not restore "Sunday's full plus six increments": you restore Thursday's state, directly.
Encryption happens client-side. Data leaves encrypted, and the storage provider sees only opaque blocks. That is what makes backing up to a third party acceptable.
# Client-side encrypted, deduplicated, to remote storage
restic -r s3:provider/my-bucket backup /app/data /app/public/uploads
# Retention is a command, not a home-made script
restic -r s3:provider/my-bucket forget \
--keep-daily 30 --keep-weekly 12 --keep-monthly 12 --prune
# Verify repository integrity, not merely its presence
restic -r s3:provider/my-bucket check --read-data-subset=5%
That last command is worth knowing: it actually re-reads part of the data and verifies the hashes. That is the difference between "the repository exists" and "the repository is readable".
The encryption key trap
Client-side encryption introduces a new point of failure: losing the key means losing the backups, permanently and without recourse.
So the key must not be stored only on the machine being backed up — otherwise losing the machine also takes away the means of reading its backups. Keep a copy elsewhere, offline, and test that it works by restoring from that copy.
A minimal but honest plan
For a site or application of modest size, this is what holds up:
- A daily snapshot of the database, consistent, kept thirty days.
- A weekly archive of uploaded files, kept three months.
- An off-site copy, with a provider different from the one hosting you.
- An alert if the backup did not run — not only if it fails loudly. Absence of signal is the most important signal.
- A quarterly test restore, timed, with the procedure written down.
- Decryption secrets kept somewhere other than the machine being backed up.
None of this is sophisticated. It is mostly regular, and verified.
What to take away
Redundancy keeps the service running when hardware fails. Backups bring the data back when it is lost. Both are necessary, neither replaces the other, and confusing them is exactly the kind of mistake you only notice on the day it is too late.
And the only question that really matters: when did you last restore? If the answer is "never", you do not yet know whether you have backups.
Tags
- Hosting
- Backups
- Security