Results.

SCEPTRA.TECH

Test a Gzip File Before Trusting the Export, Without Expanding It to Disk

Gzip export checks: test the stream, read the result, then validate the data

A file ending in .gz is not automatically a usable backup. Before replacing a source file or declaring a transfer complete, I would check the compressed stream itself. GNU gzip has a test mode for that job, and it does not require writing an expanded copy beside the download.

The useful boundary is this: a compression integrity check can report a problem with the compressed data. It cannot prove that you backed up the right information or that the restored application will work.

Start with one known compressed file

This example is for GNU gzip in a terminal, commonly available on Linux and in some other command-line environments. Other implementations can differ, so check your installed tool's help rather than assuming every system has the same options and exit codes. On Windows, these are not PowerShell built-in commands.

Suppose you have a trusted export named report.csv.gz in the current folder. Use test mode, with verbose reporting:

gzip -t -v ./report.csv.gz

The GNU manual describes -t as checking compressed-file integrity and quitting. This is not the normal decompression operation. Keep the exact filename scoped to the file you intend to check, rather than starting with a wildcard over a whole directory.

Read any error or warning that appears. A missing file, a file that is not in the expected format and damaged compressed data are different problems. Do not label every failed check as corruption without reading the message.

Check the command's result, not just the absence of text

For GNU gzip, the documented exit status is normally 0 for success, 1 for an error and 2 for a warning. In a POSIX-style shell such as Bash, you can inspect the status immediately after the command:

gzip -t ./report.csv.gz
printf 'gzip exit status: %s' "$?"

Run the status print directly after gzip. Another command would replace the status you meant to inspect. This shell example is illustrative, not a claim that a particular export was tested. If you put a check into automation, handle warnings deliberately instead of silently treating every non-error-looking message as success.

Do not confuse listing with testing

The -l option lists information such as compressed and uncompressed sizes. That is useful metadata, but it is a different operation from -t. A plausible filename and size do not substitute for the integrity check.

There are size-reporting limits too. The gzip format stores the original input size modulo 2 to the power of 32. GNU gzip's documentation also notes that, for a compressed file made of concatenated members, the size and CRC reported by the list option apply only to the last member. Do not use one listed number as an unquestioned capacity estimate for every large or multi-member file.

Keep the original until the real validation is done

If the test reports a problem, preserve the file and its error details while you obtain a fresh export or transfer from the known source. Do not add force or quiet options merely to make a warning disappear. Keep an existing good backup until you have verified the replacement.

If the compression test succeeds, continue with the check that matches the data. A CSV export still needs its expected columns and records checked. A database backup still needs a supported restore test in an appropriate non-production environment. A valid compressed stream can contain the wrong day's report, an empty export or data from the wrong account.

The gzip format includes a CRC-32 value for the uncompressed data. That consistency check is not an identity check on the sender, a malware scan or proof of application correctness. Test only files you have a reason to process, and remember that reading a large compressed stream still takes work even when no expanded output file is written.

Sources

Comments