Skip to content
Tutorials Center
My learning

Topics

Lesson 39 of 55 ยท Security and Care

Backups and Data Recovery

Learn why backups matter, the 3-2-1 rule, full versus incremental backups, versioning, how to test a restore, and what data recovery tools can and cannot do.

Every storage device will eventually fail, and many files are lost much sooner for ordinary reasons: a deleted folder, a spilled drink, a stolen laptop, an overwritten document, ransomware. The only reliable protection is a backup: a separate, extra copy of your data that you can bring back after something goes wrong. People often say they will start backing up "soon". The best time is before the day you need it.

This lesson explains what a good backup plan looks like, the difference between full and incremental backups, how versioning protects against mistakes, why you must test restoring, and what "data recovery" can realistically do when you had no backup. It follows Malware, Phishing and Safe Habits and uses what you learned about storage in Storage: HDD, SSD and Beyond.

What a backup is (and is not)

A backup is a copy that is independent of the original: if the original is damaged, deleted or encrypted, the copy is not affected. That rules out some things people mistake for backups:

  • RAID (two disks mirroring each other) protects against one disk dying. It copies a mistake or a virus to both disks instantly. It is availability, not backup.
  • Sync services that mirror a folder to every device (many cloud drives) copy a deletion or an encrypted file everywhere. Some keep a recycle bin or version history for a while; that helps, but it is a safety net, not a complete plan.
  • A copy in the same folder, or on the same disk, disappears with the disk.

The 3-2-1 rule

A simple rule of thumb that has served well for years:

  • 3 copies of your data: the original plus two backups.
  • 2 different kinds of storage, such as the internal SSD and an external drive, so one failure type cannot take both.
  • 1 copy kept somewhere else (off-site): in the cloud or at another location, so a fire, flood or theft does not take everything.
flowchart LR
  O["Original<br/>(laptop SSD)"] --> L["Local backup<br/>(external drive)"]
  O --> C["Off-site backup<br/>(cloud or another location)"]

Three copies, on at least two kinds of media, with one away from home.

Some people add a fourth idea: one copy that is offline or immutable (disconnected, or set so it cannot be altered), because ransomware that reaches a connected backup drive can encrypt it too. The stand-in below checks a plan against these rules.

JS Does this plan follow 3-2-1?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Full, incremental and differential backups

How much does each backup run copy? There are three common strategies:

  • A full backup copies everything. It is the simplest to restore (one set holds all) but takes the most time and space.
  • An incremental backup copies only what changed since the previous backup of any kind. It is small and fast, but a restore needs the last full backup plus every incremental after it, applied in order. If one link in the chain is lost or damaged, later changes cannot be rebuilt correctly.
  • A differential backup copies everything changed since the last full backup. It grows each day, but a restore needs only the full backup plus the latest differential.
Full Differential Incremental
Copies each run everything changes since last full changes since last backup
Backup size largest grows over time smallest
Restore needs 1 set full + last differential full + all incrementals
Restore speed fastest fast slowest

Backup tools decide what changed by comparing modification times or by computing a fingerprint (a hash, as in Passwords, Hashing and Encryption) of each file and comparing it with the last run. Many tools also work at the level of blocks inside big files, so a one-line change to a large file does not copy the whole thing again.

The simulator below keeps a small "disk", takes a full backup and then incrementals, and restores. Its fingerprint is a quick toy function; real tools use strong hashes. It also shows what happens when a link in the chain goes missing.

JS An incremental backup simulator

Press Run (or Ctrl + Enter) to see the console output here.

No output.

In the last line, notes.txt is back to buy milk: the edit stored in the lost incremental is gone, and the restore silently gave an older version. That is why incremental chains need care, and why many programs write a fresh full backup regularly (for example, weekly).

Versioning: going back in time

Some disasters are not a missing file but a wrong file: you saved over a good document, or ransomware changed it last night and the nightly backup copied the damage. Versioning (keeping several older snapshots) solves this. Instead of one backup that is overwritten every day, you keep a history, often thinned out as it ages: hourly for a day, daily for a month, monthly for a year. Operating systems offer this with features such as File History and Time Machine, and many cloud services keep older versions for 30 days or more.

Versioning is also the answer to a slow-motion problem: silent corruption (also called bit rot), where a file becomes damaged and no one notices for months. If you only keep the latest copy of everything, the corrupted copy eventually replaces the healthy one.

Test your restore

A backup you have never restored is a hope, not a plan. Backup jobs can fail quietly: a full disk, a changed password, an unplugged drive, files in use and skipped, or an encryption key you no longer have. Make these habits:

  1. Automate the backup so it does not depend on memory. Schedule it daily, weekly or continuously.
  2. Check the reports or notifications for failures.
  3. Restore a few files every few months, open them and check that they are complete. Occasionally rehearse restoring everything to a spare disk.
  4. Protect the backup itself: if you encrypt it, store the key or passphrase separately (for example in your password manager and on paper), or the backup is unreadable.
  5. Know what is covered. Many people back up documents but forget photos on their phone, the browser's saved passwords, email that exists only on a server, or the data of apps installed from the web.

When there is no backup: data recovery

If a file disappears, first stop using the drive: every new write may overwrite what you want to recover. Then check the places that cost nothing: the recycle bin or trash, file-history or "previous versions" features, the cloud service's trash and version history, and other devices that synced the file.

If those fail, recovery software may help in one situation. As explained in File Systems, deleting a file usually just removes its entry and marks its blocks as free; the contents remain until reused. Recovery tools scan the drive for those leftover blocks and rebuild files, often without names and folders. Their success depends on conditions:

  • On a hard disk, an ordinary delete is often recoverable until new data overwrites the space.
  • On an SSD, the TRIM command tells the drive which blocks are unused so it can erase them in the background, so deleted data often vanishes quickly and cannot be recovered.
  • On phones and encrypted disks, data is encrypted with a key; if the key is gone, the content is unreadable noise.
  • After a full format or secure erase, or when blocks were overwritten, recovery is not possible.
  • For a physically damaged drive (clicking noises, not detected at all), stop powering it. Only a specialist lab with a clean room can try, at a high cost and without guarantee.

Recovery is a last resort with uncertain results. A $50-a-year backup service is far cheaper and more dependable than a $1,000 recovery attempt.

JS Why a deleted file is sometimes recoverable

Press Run (or Ctrl + Enter) to see the console output here.

No output.

After the delete the whole letter can still be read from the free blocks. After one new file reuses some of them, only part of the letter survives, and every further write makes it worse. That is why you should stop using a drive as soon as you notice a loss.

What is real here and what is a stand-in? The 3-2-1 rule, backup types, versioning, restore testing and the limits of recovery are real practice. The simulators are toy models: real backup tools store data in compressed, often encrypted archives or snapshots, track changes with file-system journals, and verify what they wrote. The block model keeps the idea that "delete" changes bookkeeping while the data stays until it is overwritten (and TRIM on SSDs changes that).

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does the 3-2-1 rule recommend?

    Three copies, two kinds of storage and one copy away from the original location protect against most single failures.
  2. 2. A disk in a RAID mirror dies. Does that make RAID a backup?

    RAID keeps a machine running through a disk failure, but both disks always hold the same content, mistakes included.
  3. 3. Which restore needs a full backup plus every backup made after it, applied in order?

    Each incremental stores only changes since the previous backup, so every link in the chain is needed.
  4. 4. Why is it worth restoring a few files from your backup now and then?

    Full disks, expired credentials or missing keys can ruin backups without any visible sign until you try to use them.
  5. 5. Why is deleted-file recovery often impossible on a modern SSD?

    After TRIM, the drive may erase blocks it was told are unused, so the leftovers a recovery tool needs may be gone quickly.

Summary

  • A backup is an independent extra copy; RAID and sync folders are not backups because mistakes and ransomware spread to them.
  • Follow 3-2-1: three copies, two kinds of media, one off-site, and consider one offline or immutable copy.
  • Full backups are simple and large; incrementals are small but depend on a complete chain; differentials sit in between.
  • Versioning keeps older snapshots so you can undo a bad save or a silent corruption.
  • Automate backups, watch for failures, protect encryption keys, and test restores regularly.
  • Recovery tools can sometimes find deleted data on hard disks, but TRIM, encryption, overwriting and physical damage often make it impossible.

Next, learn to find and fix problems: Troubleshooting, Performance and Upgrades.