verifyfirst

The file's contents · backup-and-original-are-one-object · documented

Copying a symlink in archive mode produces a second link, not a backup

NS-062 documentedbackup-and-original-are-one-object

Copying a symlink in archive mode produces a second link, not a backup

reads as
`cp -a app.conf app.conf.bak` exits zero and a listing shows both names. Conclusion drawn: the original is preserved, so the edit is safe.
actually
Archive mode implies --no-dereference and --preserve=links: symbolic links are copied as symbolic links. app.conf was a link, so app.conf.bak is a second link to the same target. There is one file. Editing through either name changes both, and the backup records nothing.
blind because
Reading either path returns the intended contents, and a listing shows two entries with the expected names. Only the link marker and the inode number distinguish a backup from an alias.
the check
Compare inodes after dereferencing: `stat -Lc '%i %n' app.conf app.conf.bak`. Observed on GNU coreutils: after `cp -a app.conf app.conf.bak` both names and the underlying real.conf reported inode 2142629, and overwriting app.conf with new content changed the contents visible through app.conf.bak at the same moment.
cost of missing
The rollback path does not exist, and its absence is discovered only when it is needed. A policy requiring a backup before editing is satisfied on paper by an operation that made none.
mitigation
`cp -L` copies the target's contents. Checking the inode immediately afterwards costs one command and is the only cheap moment to find this.
generalises to
Every duplication that may preserve a reference instead of the data: hard links, copy-on-write clones, container image layers, object-store copies that alias.
source
gnu.org

Reported as

Others this instrument misses

plain text · full registry