Backup Studio

How to know your backup actually worked

A finished copy isn't always a good copy. Here's how checking works, and how to do it.

By Liam McGarrigle · · 5 min read

The photo on the card
On the cardDSC_4127.NEF · 48.2 MB
What you shot.
The copy: the bottom of the photo is gray and striped
The copyDSC_4127.NEF · 48.2 MB
Finished copying. No error.
What a bad copy can look like. Sometimes the file won't open at all.

You may have seen a photo like this in a backup before. The top looks fine and the bottom is gray, or full of colored stripes. Even more often, the photo won't open at all. The strange part is that the copy usually looked perfect when it finished: same name, same size, no error.

How a copy goes bad

Usually it's something boring. A loose cable, a card reader on its way out, a drive with a weak spot, or a computer that says it saved something a moment before it really did. Most of the time nothing warns you. The copy finishes and it looks like it worked.

It happens more than you'd think. A study of 1.53 million drives in real storage systems found more than 400,000 cases where data read back from a drive didn't match the fingerprint stored with it.

1.53M
drives in real storage systems
400,000+
times the data read back didn't match its fingerprint
From the study, over 41 months of records.

Dragging a folder in Finder won't catch this. Finder copies the files and tells you about errors it runs into along the way, but it never reads the copy back to compare it with the card.

How checking works: fingerprints

The fix is to read the copy back and compare it with the original. The usual way to do that is with a fingerprint (you'll also see it called a checksum).

A fingerprint is a short code generated from every pixel of a photo. Change a single pixel anywhere and the code, that fingerprint, comes out completely different. So you generate the fingerprint of the photo on the card, then the fingerprint of the copy, and compare the two short codes.

A good copy
On the card9f2c 81ab 44e0 d7c3
The copy9f2c 81ab 44e0 d7c3 Match
One pixel changed
On the card9f2c 81ab 44e0 d7c3
The copy3b71 0ce9 a5d2 6f48 Copy it again
The codes are shortened here. Real ones are longer and work the same way.

Two details separate a real check from one that only looks like one:

  1. 1
    Read the copy from the drive itself
    Your Mac keeps files it just copied in memory to speed things up. A careless check reads that memory instead of the drive, and of course the memory matches. A real check makes sure what it compares came off the drive.
  2. 2
    Check every file
    Comparing sizes or counting photos only tells you the copy is the right size. A broken photo usually is.

Checking your copies yourself

The simplest check is to open every photo from the import and look at it. It's slow, and it won't catch everything, but a broken copy usually shows up as a photo that won't open, or one that's gray partway down.

This next part is more advanced, but it's how you can check fingerprints by hand. Terminal on a Mac has a fingerprint tool built in called shasum, and this checks a whole card against its copy, as long as the copy keeps the same folders as the card.

Check a card against its copy in Terminal

1. Make a list of fingerprints from the card: cd /Volumes/CARD && find . -type f -not -path './.*' -exec shasum -a 256 {} + > ~/card.txt

2. Eject your backup drive and plug it back in, so your Mac reads the copy from the drive and not from memory.

3. Go to the copy and check it against the list: cd "/Volumes/Backup/Maya and Jonah" && shasum -a 256 -c ~/card.txt

Every line should end in OK. Swap in your own card and folder names.

If you don't want to work out fingerprints yourself, I built it into Backup Studio. An import isn't complete until every photo's fingerprint has been generated and checked against the original, so you know you're backing up your clients' memories and not files full of static.

Questions

What does it mean to verify a backup?
It means reading the copy back and making sure it matches the original, usually by comparing fingerprints (also called checksums). Without that, all you know is that the copy finished.
Is comparing file sizes enough?
No. A damaged photo is often exactly the same size as a good one, because the damage changes pixels inside the file without adding or removing any.
Does Finder check the files it copies?
Not the way a backup needs. Finder tells you about errors it runs into while copying, but it doesn't read the copy back afterward and compare it with the original.

Sources