1

Scenario: Using Linux shell to back up a directory of many sub files and compressing the data with ‘tar -cvpJf filename.tar /savedir/’.

Goal: Using shell — checksum or validate the newly created ‘.tar’ against the original directory.

Limitations: Solution cannot involve downloading 3rd party support libraries. User cannot be part of the process.

Comments: Basically, I am wondering if there is a tar flag I am missing that will validate upon creation of the tar, or maybe I can pipe the tar into some process?

5
  • 1
    I don't understand this question. The checksum of the tar archive will be different from whatever you used to create it. Commented Jul 22, 2021 at 18:26
  • 1
    You could extract the tar file into a temp directory (mkdir /foo && cd /foo && tar -xvf .../filename.tar) and then diff -r the two directories (diff -r /savedir /foo). Or, would re-creating the tar archive produce an identical file? (tar -cvpJf - /savedir/ | diff filename.tar -) Commented Jul 22, 2021 at 20:41
  • This will involve a little more effort than you seem to think it will. It can be done; see this, and this, and this for example. It's not a tar option IOW. Commented Jul 22, 2021 at 22:40
  • "I am wondering if there is a tar flag I am missing": Try -W or --verify (I don't know if this option is only available in GNU tar or POSIX tar, but since you use Linux, it should work). Commented Jul 23, 2021 at 1:40
  • @berndbausch The features of gtar to compare TAR archives against the filesystem are very limited. I recommend the older and more mature star that supports a -diff option that allows to compare the content and any meta data and even more: star allows to control which meta data is to be compared by specifying a list with the option diffopts= Commented Jul 23, 2021 at 10:51

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.