1import hashlib, os, shutil2def sha(path):3 with open(path, "rb") as f:4 return hashlib.sha256(5 f.read()).hexdigest()6saved = sha("orders.csv")7os.makedirs("vault", exist_ok=True)8shutil.copy2("orders.csv", "vault")9# ...ransomware hits orders.csv...10shutil.copy2("vault/orders.csv", ".")11print(sha("orders.csv") == saved)MALWAREorders.csvsha 6d2443d8…saved = ?NASempty01OFFLINEempty
The program, the server, the NAS and the offline vaultSaved fingerprint, match lamp, RPO and RTO clockTokens: fingerprint, backup copies, ransomware, restored fileOn the left, an eleven-line Python program: it saves a SHA-256 fingerprint of orders.csv, copies the file to a vault, and later restores it and checks the fingerprint. Following the 3-2-1 rule, the shop keeps the server copy, a NAS copy on the network and an offline vault copy that is unplugged after each backup. Ransomware encrypts the server and the always-connected NAS, but cannot reach the vault; the shop isolates, rebuilds, restores from the vault, checks the digest and practises against its RPO and RTO. The times are one worked example, not a standard: a nightly backup at 02:00, an attack at 14:00, an RTO of 8 hours and a 3-hour drill. Real targets come from how much loss and downtime each business process can bear.

Making good backups

  1. No defence stops every attack, so resilient organisations plan to recover. A backup is a separate copy of data you can restore from. Our example: a small shop keeps orders.csv on its server, with a network drive (NAS) and an offline vault.

Ransomware strikes

Recovering

What happens

;; step 1/11 · resilience
resilience   keep working, and recover when
             something gets through
backup       a separate copy you can restore from
server       orders.csv (the primary copy)
NAS          network drive, always connected
vault        a drive kept offline and off-site

The times are one worked example, not a standard: a nightly backup at 02:00, an attack at 14:00, an RTO of 8 hours and a 3-hour drill. Real targets come from how much loss and downtime each business process can bear. The program runs as is with Python 3 next to a file called orders.csv. Real backup tools add schedules, many versions, encryption and logs; the idea is the same.