0

I have a 50.9 GB file which is a backup of my home folder on Ubuntu 12.04. I compressed this file using tar on Terminal from my sda (ext4) drive to sdb (ext4). The command I used was

tar cvfz /media/2ndHDD/home.tar /home/<my_username>

I was getting this error after the compression:

tar: Exiting with failure status due to previous errors.

I repeated the compression thrice but same error I'm getting when the compression is finished. Because I'm already too exhausted of this on the third attempt (especially that it took me whole day), I just disregarded the error and was hoping it won't affect when I decompress the file.

After that, I installed a new OS which is Ubuntu 14.04 to my sda drive. After the installation, I attempted to untar the file I compressed a while ago by using this

tar xvf home.tar

but I'm getting this error:

gzip: stdin: invalid compressed data--format violated
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

So I tried to gzip the file using

gzip home.tar

and waited for almost 1 hour to finish. And after that, I decompressed it again using gzip this time.

tar -xvzf home.tar.gz

The process just can't finish and will stop after 15 minutes which leaves the created 'home' folder incomplete of files I'm expecting. I repeated the process over and over again but won't really finish.

Is there any way I can recover this huge compressed file? I already tried gzrecover (http://fosshelp.blogspot.com/2013/04/howto-recover-corrupted-targz-file.html) but always fails. Could it also be possible that I already lost my files when I attempted to convert it to gzip? I really regret why I didn't just copy the home folder uncompressed. :(

UPDATE: Just now, I attempted to convert it back to tar by using this command

gzip -d home.tar.gz

and decompressed it by running

tar xvf home.tar

now I'm getting this error:

gzip: stdin: invalid compressed data--format violated
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

And even just listing down the files inside the tar file won't finish processing

tar -tvf home.tar

I will still get the same error above

UPDATE (01/11/2015): I tried to run strace gunzip home.tar.gz and after about 15-20 minutes I was getting these:

read(3, "\231\300\2678\242p\206\371\341\322\352\312\374\271?\252.\1775sC\330|D$PF$\10r\362V"..., 32768) = 32768
write(4, "\256Y\341\224\362Nn\315\316\373>\31\202\275c\373\266\265\345\27 R\312\2\221b'6\263\321\10F"..., 32768) = 32768
read(3, "[\366\"\r\265\244\3s\201\223b\n\267\364\34\247Ej\210tF\22\255B\254\223\216E\26\242\321\210"..., 32768) = 32768
write(4, "\n1g\201\\m\231\364\352@\"%\207\"Q+\37a^!8\226\233\204\244\v\334&i\361\2a"..., 32768) = 32768
read(3, "\222\327\351\337(\376\376?\246AzC\371\231\200${V\361\310W9.\3571a\362\357\251\306o\234"..., 32768) = 32768
write(4, "\346\216sH\250\272\264T\335\356<?\377\266\272o{\32\21\264\367\34\377w\327\220\324\313\231\2775\337"..., 32768) = 32768
read(3, "\266\276\345\213\277}G\235\355\360\326\232\244\353Z\\\215\222g\354\202\356\351\303G~\210\363b\31\17P"..., 32768) = 32768
write(4, "\326!1\332\213\253\276\327\222<\345\25\210\366\266\337uSkj>\345$\257\225\2q\321^8Jk"..., 32768) = 32768
read(3, "~D\212\373\372\"\373\367m0\322%\365S\377\335\331\336\376RB\037727e'\371#S\224\223"..., 32768) = 26366
read(3, "", 6402)                       = 0
write(4, "\23\320\"\0059\24\20\"\5#M\210I\323\320\363T\220N\321\301\207\\\327(I\204\362\371\377\32!"..., 32768) = 32768
write(4, " \6\325\33\246\324\35\240h\225B\270\312\207\211\340)\314\27\17\"pv\2232?\"0Sez\247"..., 14402) = 14402
close(3)                                = 0
utimensat(4, NULL, {{1420884866, 686801693}, {1420818997, 36136000}}, 0) = 0
fchown32(4, 1000, 1000)                 = 0
fchmod(4, 0666)                         = 0
close(4)                                = 0
rt_sigprocmask(SIG_BLOCK, [HUP INT PIPE TERM XCPU XFSZ], [], 8) = 0
unlink("home.tar.gz")                   = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
_llseek(0, 0, 0xbf8c86a0, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

With the output above, is it possible that I can still recover it? I just don't know where to start :(

  • It would be more helpful if instead of writing what you did, you included a full list of commands (in a sequence and exactly as you wrote them) that you used and then refer to the commands below, writing which have failed. – Marcin Kaminski Jan 10 '15 at 12:38
  • edited it and hopefully it's a bit clearer now? – JoenasE Jan 10 '15 at 14:38
3

First you created a gzipped tar archive with:

tar cvfz /media/2ndHDD/home.tar /home/<my_username>

You ignored the errors and didn't scroll up to see what they were (pretty bad idea). Then you tried to unpack the tar file (even without the -z option, it should have recognised that it's a gzipped tar archive):

tar xvf home.tar

It didn't work and you compressed the already compressed (with the same compression algorithm) archive. Can you explain the thought process here?

gzip home.tar

Then you tried unpacking a gzipped tarball which has been gzipped again:

tar -xvzf home.tar.gz

Let me ask - do you know what you're trying to achieve or is that all just trying random commands, "let's see what happens" without paying attention to what they actually do?

I strongly recommend better planning backups in the future and paying attention to errors which were there, because maybe the developers of tar thought they were important enough (after all, it's a backup - pretty important usually) that they should be repeated at the end of the process...

This time, I'd try to first see what your the actual format of your archive (or what's left of it) is. Use:

file <archive_file>

If it is indeed gzipped tar archive and it's throwing those errors, I'm afraid you're out of luck.

UPDATE: I read that the current file you have is a gzip archive:

home.tar: gzip compressed data, from Unix, last modified: Fri Jan  9 22:07:25 2015.

Make sure you have, depending on the type of compressed data, I'm guessing 4 times as much free space on the partition where you're doing this. Move the home.tar outside of the /home directory if it already isn't somewhere else.

Run the following on it as the last resort to unpack it:

gunzip -c home.tar > home1.tar
file home1.tar

Fist command will try to unzip the home.tar file into home1.tar. The other will tell you what home1.tar actually is. It could still be another gzip archive.

If file says that it is gzipped data, run:

gunzip -c home1.tar > home2.tar

Make sure you pay attention to file names. Find out what home2.tar is now:

file home2.tar

Again, if it's gzipped data, run gunzip on it again as above, this time redirecting to home3.tar. Run file on it again.

If it says:

homeX.tar: POSIX tar archive (GNU)

Try listing its contents with:

tar taf homeX.tar

and if this works, try unpacking the tar file.

  • I tried to gzip home.tar it because I thought it will fix the error gzip: stdin: invalid compressed data--format violated. This is my first time to use the command when unpacking a tarball. Usually I will just do it in the Nautilus but it failed so that's why I tried my luck with using the command. It's also my first time to backup such huge file when reinstalling an Ubuntu OS. By the way, file home.tar returns this home.tar: gzip compressed data, from Unix, last modified: Fri Jan 9 22:07:25 2015. – JoenasE Jan 11 '15 at 2:39
  • Yeah I believe I'm out of luck already because I tried to recover it overnight with PhotoRec (I only recovered unknown and useless files with unknown characters on them e.g. on the txt files) and on Windows with 7zip, DataNumen Tar Repair, and even with WinRar. Still no luck :( What a stupid mistake! – JoenasE Jan 11 '15 at 2:43

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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