I've had quite a struggle with tar incremental backups recently. Feels like a bug, even if only in the documentation. Curious to hear the wisdom of this crowd. Synopsis: I want to make an archive. Then, incrementally archive some time later. Extracting the archives should leave destination with results that match source (at time of last archive), including the *absence* of files captured in earlier archives then *deleted* from source file system prior to subsequent archive. This would not work as I anticipated, nor as the docs indicated (by my reading), nor as ChatGPT 4o-mini or Claude Haiku 3.5 all agreed should work. The key is using --listed-incremental=snapshot.file: # touch file1 file2 # tar --listed-incremental=snapshot.file 1.tar file? file1 file2 # rm file2 # touch file3 # tar --listed-incremental=snapshot.file 2.tar file? file3 # mkdir untar # cd untar # tar --listed-incremental=../snapshot.file -xvvf ../1.tar file1 file2 # tar --listed-incremental=../snapshot.file -xvvf ../2.tar file3 # ls -l file1 file2 file3 ^-- file2 should *not* exist at this point, per docs: https://www.gnu.org/software/tar/manual/html_node/Incremental-Dumps.html
The option ‘--listed-incremental’ instructs tar to operate on an incremental archive with additional metadata stored in a standalone file, called a snapshot file. The purpose of this file is to help determine which files have been changed, added or *deleted* since the last backup
Turns out, it will *only* work if the source to tar does not contain a file glob, like `file?`. The snapshot file will contain no info about what was archived and tar won't therefore know to remove file2. Does this make sense, or sound like a bug? Turns out, it can be made to work: Extracting ../2.tar with --incremental-listed: drwxr-xr-x root/root 15 2025-10-26 21:48 ./source/ tar: Deleting ‘./source/file2’ -rw-r--r-- root/root 0 2025-10-26 21:48 ./source/file3 If I run `tar ... file*` then no incremental archive. If I run `tar ... $folder_name` then everything works as desired. Very weird, counter-intuitive, and not documented (IMHO). What do you think?