File backup tools

Preserve required metadata

Decide whether ownership, permissions, timestamps, links, extended attributes, and application metadata must survive.

File bytes alone may not be enough to recover. A restored web server with the right content but the wrong ownership won’t serve pages. A restored script without its executable bit won’t run. Executable bits, ownership, links, access controls, and extended attributes affect how a service behaves, just like the content does.

For personal documents, bytes are usually enough. For a system restore, metadata is part of the data.

Capture a baseline

You can’t verify metadata survived if you don’t know what it looked like. Record a baseline before backing up:

stat notes/report.txt
getfacl notes/report.txt 2>/dev/null || true
ls -l@ notes/report.txt 2>/dev/null || true

stat shows ownership, mode, and the three timestamps. getfacl shows POSIX ACLs on Linux. ls -l@ shows extended attributes on macOS. The || true keeps the script from failing on platforms where a command doesn’t exist, so this baseline runs anywhere.

Save that output next to your restore documentation. After a restore, run the same commands and compare:

stat restored/notes/report.txt
# compare Uid, Gid, Access mode with the baseline

Know what your tools preserve

Each tool has limits. rsync --archive preserves permissions, times, and symlinks. It needs the extra -A flag for ACLs and -X for extended attributes. tar stores ownership in the archive, but only restores it when you extract as root. As a regular user, every restored file becomes yours.

Restore to a filesystem that supports the metadata you need, then compare. If you accept a conversion, write it down.

Where this bites

Don’t assume a cloud sync tool or a FAT-formatted disk preserves Unix ownership and permissions. FAT and exFAT, the default format on most external drives, have no concept of Unix owners or modes. Copy /etc to an exFAT disk and back, and every file comes back owned by you with mangled permissions. Dropbox-style sync clients keep the content and quietly drop the rest.

The fix is one of two things. Format the destination properly (ext4, APFS). Or use an archive format like tar, which carries the metadata inside the file itself.

Try it: copy a file with the executable bit set to an exFAT drive, copy it back, and run stat on both. The difference is the lesson.

Lesson completed