views:

752

answers:

2

I also found this link. But I was wondering if there is any ready made command line solution?

+1  A: 

you could probably use the gzip -t option to test the files integrity

http://linux.about.com/od/commands/l/blcmdl1_gzip.htm

from: http://unix.ittoolbox.com/groups/technical-functional/shellscript-l/how-to-test-file-integrity-of-targz-1138880

To test the gzip file is not corrupt:

gunzip -t file.gz

To test the tar file inside is not corrupt:

gunzip -c file.gz | tar tf file.tar.gz

As part of the backup you could probably just run the latter command and check the value of $? afterwards for a 0 (success) value. If either the tar or the gzip has an issue, $? will have a non zero value.

John Boker
+2  A: 

G'day,

what about just getting a listing of the tarball and throw away the output?

tar -tvzf my_tar.tar.gz >/dev/null

rather than uncompressing the file?

Rob Wells