0

I created a backup with

# tar -cvpzf /run/media/user/XYZ/backup.tar.gz --exclude=/run/media/user/root/mnt /run/media/user/root/

now I need the backup and when I tried to extract the tar.gz archive I accidentally deleted the backup file:

#tar -xvpzf /run/media/user/XYZ/backup.tar.gz -C /run/media/user/otherDevice/
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now

I got the error nearly instantly so I guess only some bits are overwritten. I still can see the file but its size is 0 Bytes. Partition type is NTFS. Can someone explain what happened and how to restore the file?

MC68020
  • 7,981
c4tz3r
  • 1

1 Answers1

2

There is a tool ntfsundelete in ntfsprogs package: https://manpages.ubuntu.com/manpages/trusty/man8/ntfsprogs.8.html

Since you have NTFS storage, you can also try using Windows based tools (there are several of them with various degree of usability).

But most likely, you do not need to restore the archive. First of all, if the archive you see now is zero byte length - the file exists, it is not deleted.

Second, tar does not modify the archive file on extraction. The zero length of archive file usually means that when you created the backup - it failed by some reason. And you just missed that.

What you can/should do now - try to create the backup again from the original files. And check is it good or not. tar -t will help with that.

White Owl
  • 5,129