I was archiving several large directories (a total of a few TBs in size) using the command:

$ tar -vcf directories.tar --remove-files dir1/ dir2/ dir3/ dir4/

Whilst manovering through GNU screen I accidently cancelled the proccess! (CTRL-C)

dir1 and dir2 are now deleted and can't a seem to access anything in the archive:

$ tar -tvf directories.tar 
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
$ file directories.tar 
directories.tar: empty

Is there anyway that I can continue the archiving process so that it can complete properly or recovering the data from the broken tar archive?

I'm using Ubuntu MATE.

  • Are you sure this is all you did? I just tried to replicate your setup on SuSE and Ubuntu 16.04-LTS, and in both cases the --recover flag was not available (check whether it is on your system), but tar was able to read back all files except the last one. Whatever I attempted, tar never failed to recognize the file as one of its own. – LSerni Jan 7 '18 at 13:50
  • What's the size of the tar file? Does it contain anything at all? What does the file command report back? – Alexander Jan 7 '18 at 14:13
  • @LSerni Yes I'm pretty sure this is all I did. It doesn't recognise the --recover flag. How were you reading back the files? @Alexander Yes I think you're on to something here. As stated above: $ file directories.tar directories.tar: empty Looking at the actual size though gives: du -h directories.tar 0 directories.tar So it seems that nothing was saved but doesn't it check that it's added to the archive before it deletes the original? – ojunk Jan 7 '18 at 14:19
  • This is very strange. It should not have deleted the files unless they had been indeed archived. Has free disk space increased at all? Was there enough disk space? Is it possible that the TAR file is actually elsewhere (e.g. you launched tar twice or something like that? I myself did such more than once). – LSerni Jan 7 '18 at 14:57
  • @LSerni Thanks for all the help. Yes the amount of free space has significantly increased and thinking about it the disk would have been very close to maximum capacity. Is this a terrible mistake for me to make? How would I find out that I launched tar twice and what would happen to the data? – ojunk Jan 7 '18 at 15:40

If the tar file is empty, then there is no data to recover anything from.

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.