Tar – How to Verify a Tar Archive

tar

I know that you can do -W when creating an archive, but how do you verify and already-created archive? tvWf says it's not a valid tar archive?

$ mkdir tmp
$ echo asdkfjh > tmp/a
$ echo qweroiu > tmp/b
$ ls
tmp
$ tar cvf archive.tar tmp
tmp/
tmp/a
tmp/b
$ tar tvWf archive.tar
tar: This does not look like a tar archive
tar: Skipping to next header
tar: VERIFY FAILURE: 1 invalid header detected
tar: Error exit delayed from previous errors

Same thing happens with both tar 1.15 (which is the system default on centos 5) and 1.26 (which is the newest version from gnu).

Best Answer

You can't use W with t.

mkdir tmp
echo bdb > tmp/a
echo bdb > tmp/b

tar cvf archive.tar tmp
tmp/
tmp/a
tmp/b

ls -l archive.tar
-rw-r--r-- 1 tony tony 10240 Jun 23 05:57 archive.tar

tar tvf archive.tar
drwxr-sr-x tony/tony         0 2011-06-23 05:57 tmp/
-rw-r--r-- tony/tony         4 2011-06-23 05:57 tmp/a
-rw-r--r-- tony/tony         4 2011-06-23 05:57 tmp/b

tar tvWf archive.tar
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

I believe t alone is enough to test the archive.

Related Question