I have a tar file that has been updated (e.g. tar -uf backup.tar file.txt), over time, with various iterations of a specific file (e.g. file.txt).
How can I extract an older version of the file, not the latest version?
You can use the --occurrence option:
--occurrence[=N] Process only the Nth occurrence of each file in the archive. This option is valid only when used with one of the following subcommands: --delete, --diff, --extract or --list and when a list of files is given either on the command line or via the -T option. The default N is 1.
Ex. given
$ tar tvf archive.tar
-rw-r--r-- steeldriver/steeldriver 15 2020-11-16 18:25 file
-rw-r--r-- steeldriver/steeldriver 15 2020-11-18 18:25 file
-rw-r--r-- steeldriver/steeldriver 15 2020-11-19 18:25 file
then
$ tar xvf archive.tar file --occurrence=2
file
$ ls -l file
-rw-r--r-- 1 steeldriver steeldriver 15 Nov 18 18:25 file