← Back to writing

Article · python / backup / sha256

The backup folder exists. Do the files match?

Compare source and backup content, distinguish missing and changed items, and understand why a match does not guarantee restoration.

Copying a folder to another drive is only part of the job. Seeing the folder and opening a few files does not establish that every item was copied. A missing subfolder or an older file version can remain unnoticed until it matters.

This is a general problem, not a claim about a personal data-loss incident: how does the backup differ from the source? A small, repeatable comparison gives the next investigation a clearer starting point.

Why counts are not enough

One missing file and one extra file can leave the total unchanged. Folder size cannot identify which file changed. Files with matching names may live in different subfolders or contain different data.

Match items by their relative paths within each folder, then check the contents. The source is the reference expected in the backup; the backup is the second folder being checked against it.

Four distinct results

An item present only in the source is missing from the backup. An item found only in the backup is extra. At a shared path, the contents or item type may differ. Regular files whose contents match can be listed separately.

Extra does not automatically mean unwanted. Older versions may have been kept deliberately. A comparison report should not turn into an automatic deletion list.

Checking contents with hashes

Backup Compare uses SHA-256 for this check. It reads all regular files on both sides in 1 MiB chunks and compares hashes at shared paths. Matching sizes or modification times are not substituted for a content check.

Different hashes mean different data. Matching hashes provide strong evidence that the data read matches, under SHA-256's usual collision assumption. They do not establish that the files are usable or that the source was undamaged.

Empty folders and incomplete checks

Directory structure matters too. Empty directories are reported separately. In that section, missing means an empty source directory is not also an empty directory in the backup; a nonempty directory at the same backup path also falls into this category.

An unreadable file, unsupported item or skipped link makes the check incomplete. The matching-file lists are then cleared. An empty list alone cannot tell you that everything differs or that the backup is verified.

Changes during the scan

The folders are read from a live filesystem at different times. Some observed changes are reported, but the tool does not create an atomic snapshot. Wait for copying and synchronization to finish and, when practical, pause applications writing to the folders.

Links are outside the supported comparison scope. On Windows and other fallback opening paths, a race can remain between checking for a link and opening a path. The tool is not a security boundary for a maliciously changing filesystem; use stable folders you trust.

A match still needs context

A copy of an already damaged source file can match perfectly. Permissions, ownership and additional data streams are also outside this content comparison.

Open important files in a separate test location and try the actual restoration process. Avoid overwriting working files. This answers questions a matching-file report cannot settle.

The Backup Compare usage guide, prepared as part of this same package, explains this same problem through a small read-only tool. It does not copy, delete or repair files; the user decides what to investigate next.

Source code

GitHub repository and source code: the Backup Compare implementation, synthetic tests and usage documentation are public. Review the code and test evidence before running it.

← Back to writingmuhammet.saridogan.work@gmail.com