I am running on Ubuntu 18.04.4 LTS.

I gzipped a folder with roughly 60+K files into a .tar.gz file. The compressed file had a size of 3.3Gb.

I opened the compressed file to extract some files, and realised to my shock, dismay and error, that only a few files (total file size of 6.2K) were stored in the zip!

What could possibly have gone wrong? How can the .tar.gz file have such a huge file size - yet contain files with a total filesize of around 0.5% ?

For what it's worth, none of the files I compressed are hidden files, and this is the file I used to compress the folder files:

nohup ssh me@yourbox "tar -cf - /path/to/folder" | gzip > foldername.remote.`(date +%Y%m%d)`.tar.gz &

This is the output when I run tar zvf compressed.file.tar.gz :

morpheous@ZEUS:~$ tar tzvf foobar.remote.20200717.tar.gz 
drwxr-xr-x morpheous/morpheous 0 2019-04-19 13:51 foobar/
drwxr-xr-x morpheous/morpheous 0 2020-04-16 10:46 foobar/maps/
-rw-rw-r-- morpheous/morpheous 5615 2017-11-28 08:34 foobar/maps/us_sector_XLV.csv
drwxr-xr-x morpheous/morpheous    0 2018-02-26 13:00 foobar/maps/HIX/
-rw-rw-r-- morpheous/morpheous    8 2016-07-29 08:59 foobar/maps/HIX/3350.csv
-rw-rw-r-- morpheous/morpheous   18 2018-01-28 00:37 foobar/maps/HIX/5330.csv
-rw-rw-r-- morpheous/morpheous   89 2018-01-28 00:39 foobar/maps/HIX/5370.csv
-rw-rw-r-- morpheous/morpheous   84 2018-01-28 00:38 foobar/maps/HIX/7570.csv
-rw-rw-r-- morpheous/morpheous   88 2018-01-28 00:38 foobar/maps/HIX/3720.csv
-rw-rw-r-- morpheous/morpheous   32 2018-01-28 00:39 foobar/maps/HIX/2770.csv
-rw-rw-r-- morpheous/morpheous   10 2016-07-29 08:59 foobar/maps/HIX/9570.csv
-rw-rw-r-- morpheous/morpheous   18 2016-07-29 08:59 foobar/maps/HIX/3760.csv
-rw-rw-r-- morpheous/morpheous  240 2018-01-28 00:38 foobar/maps/HIX/8980.csv
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

How do I recover my files from the compressed file?

  • 1
    With gzip, you list only content of the .gz file, which obviously is a .tar. Try tar tzf foobar.remote.20200717.tar.gz to list contents of tar.gz.
    – pLumo
    Aug 24, 2020 at 7:17
  • tar.gz means it was tard & gzipd.
    – guiverc
    Aug 24, 2020 at 7:18
  • @pLumo thanks, that helped. I'm now finally being informed that there is an error with the file. I will update my question shortly with the new information. Aug 24, 2020 at 7:29

1 Answer 1


Answering this, just in case it is useful to anyone else in the future.

These are the steps I followed:

  1. Run tar tzvf compressed-filename.tar.gz to check for errors
  2. If errors encountered, download the gzip recovery utility
  3. Build gzrt binary locally (you'll need to have make and gcc installed)
  4. Run /path/to/gzr compressed-filename.tar.gz, if all goes well, you'll have a freshly minted file named: compressed-filename.tar.recovered
  5. Run the command cpio -F compressed-filename.tar.recovered -i -v (you'll need to install cpio if you don't have it)

The last command will restore all files (not damaged - i.e. "recoverable") in to the folder it was run in. More likely than not, at some point in the recovery, cpio will abort and print the dreaded: cpio: premature end of file - but hopefully, you will have been able to retrieve the majority of your files before the unexpected EOF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.