Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If you backup your system and create a .tar.gz with thousands of files and directories, how do you easily check its integrity? (ie without having to decompress).

It's good to keep backups, but it's even better to actually make sure your backups will work when the time comes... and I'd like to know an easy way to do this.

share|improve this question
up vote 3 down vote accepted

In addition to the test suggested by Ignacio Vazquez-Abrams you might also want to create separate checksum files for your tarballs. While it doesn't catch tarballs which got corrupted during their initial creation, it will allow you to later verify that the files are still in their original state, and that they haven't gotten corrupted by disk or file system problems.

Assuming the backup backup_20110724.tar.gz is created, you might also want to have something along the following command being run:

sha256sum backup_20110724.tar.gz > backup_20110724.tar.gz.sha256

It will then create a file containing something like this:

6d5fc8993d88739247ab76c01ddf3164e585b3ed02a63362cd209d2ba463eda5  backup_20110724.tar.gz

You can then later verify the integrity doing something along these lines:

sha256sum -c backup_20110724.tar.gz.sha256
share|improve this answer

Tarballs don't have any way of checking their integrity other than decompressing, since they don't actually store checksums anywhere. Fortunately, listing the contents is usually enough to check.

tar ztvf foo.tar.gz > /dev/null

If you do want checksums then you'll need to use another format, such as zip or 7-zip.

share|improve this answer
Thanks! Would the listing of the content be a secure way of checking that the file is valid? Or could it still be corrupt? And would ej 7Zip not be a superior way to backup, then? – user60129 Jul 24 '11 at 20:16
The decompression will fail if the file is corrupt, although the files before the point of corruption would still be recoverable. 7-zip, while useful for some things, also has weaknesses that tar doesn't, such as a need to seek around in the file, which would be infeasible to perform on a tape backup. – Ignacio Vazquez-Abrams Jul 24 '11 at 20:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.