From: Ron via Talk <talk@lists.gtalug.org> To: talk@lists.gtalug.org Cc: Ron <ron@bclug.ca> Date: Tue, 28 Oct 2025 19:21:02 -0700 Subject: [GTALUG] Re: GNU tar incremental backup bug?
D. Hugh Redelmeier via Talk wrote on 2025-10-28 19:02:
If you listed a pathname of a deleted file, would tar notice and treat it as deleted? Good question.
------------------------------------------------------ Creating 2.tar WITH "--listed-incremental=file.list" tar: ./source/file2: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors ------------------------------------------------------
So, tar doesn't mark file2 as deleted in the archive, it exits.
OK, I can create a matching mental model.
Furthermore, I would hope that tar doesn't do globbing too, so quoting the argument (to prevent glob expansion by the shell) should not work. Another good question.
First, passing the source folder as "./source/*" (minus quotes) makes the incremental restore *fail*, as file2 exists when done.
Right. Isn't that how we started? ./source/* (without quoting) isn't a folder, it is a list of files. Except if ./source has no files -- then you will be passing './source/*' which won't work because it is a filename for which there is no file.
And, no, `tar` does not do its own globbing:
A makes sense. Except GNU utilities sometimes do have weird extensions.
------------------------------------------------------ Creating 2.tar WITH "--listed-incremental=file.list" tar ${incr_type} -cvvf ${tarball_2} "${tar_source}*" tar: Cowardly refusing to create an empty archive Try 'tar --help' or 'tar --usage' for more information. ------------------------------------------------------
Interesting message. I don't know/remember what strings are in those variables.
I'm still pondering if `tar` should be breaking the file.list contents when it receives parameters that are files, not folders.
What do you mean by "breaking"?
Incremental archives when parameters are files, not directories, can lead to unexpected results!
I would hope that they work according to a reasonable model. ================ I glanced at tar(1). It seems that the idea of "levels" is only partially supported. To create incremental archives of non-zero level N, you need a copy of the snapshot file created for level N-1, and use it as FILE To create a level 0 backup, use FILE to reference a non-existent file. Or use --level=0, in which case the FILE will truncate FILE. Note: the word "truncate" doesn't nail down what will happen. Perhaps the file is truncated to 0 length. The level parameter is kind of silly since any value other than 0 seems to make it a no-op. How is --level=0 better than >FILE or rm -f FILE before the tar command?