Recovering FreeBSD IMG File

Hello All,

I created an IMG file of my Freebsd7.232bit Server a few months ago using a command very similar to
Code:
dd if=/dev/sdX bs=64k conv=noerror,sync | pv | gzip -c -9 > sdX.img.gz
I do not remember the exact syntax I used. This was from a 500Gig hard drive. Anyhow it created an img file that is about 15gigs in size backup.img.gz.

Now I am trying to restore this image inside a Freebsd VM 8.1 64bit which is running under virtual box. I have mounted a 1tb external hard drive to the VM. I have tried many different ways of unzipping the img file or a command similar to this:
Code:
gunzip -c sdX.img.gz | pv | dd of=/dev/sdX conv=sync,noerror bs=64K


Anyhow, no matter what I do I keep on getting pretty much the same error being this:
Code:
gunzip: data stream error
gunzip backup.img.gz: uncompress failed
I am starting to think maybe the file is corrupt?

So I am trying to learn more about this subject but my primary reasons for doing this is I have some files in this img.gz file that I am desperately trying to get to. I am hoping someone could give me some insight into this topic or maybe tell me I am doing something fundamentally wrong since I do not know much about this topic.

Thanks,
D
 
Don't use conv=sync,noerror unless you're trying to rescue a drive with errors. It's better to find out your copy is bad when trying to make it, rather than later.

I don't think that would produce a damaged gzip file, though, since it would ignore errors before gzip got the data.

dd(1) is usually not the tool to use for backups. dump(8) is better and will always make smaller backup files unless your drive is 108% full. Backup Options For FreeBSD talks about both of these and another option, Clonezilla.
 
Thanks for your input,

I will try to avoid dd in the future since I do feel it is a bit more dangerous but perhaps more powerful. Anyhow,
I did run the command you suggested Kpa.
Code:
gzip -t backup.img.gz
And the return I got was:
Code:
gzip: data stream error
gzip: backup.img.gz: uncompress failed

So at this point I feel most of options that I know have been exhausted. It for sure does not make sense to me. Does anyone perhaps have any more suggestions or tips?

Thanks,
D
 
Looks like you error is for this reason:
Z_DATA_ERROR if the stream was freed prematurely (some input or output was discarded)

That image may have never have been usable although it's possible the corruption occured post dd.

You can try something like a # gzip -df sdX.img.gz then use mdconfig() to map the file and attempt to dump off the unmounted filesystem. Even an fsck() on the created md device might be worth a shot.

If you don't have a tested backup you don't have a backup. It's also better to store backups on resilient storage like raidz.
 
Back
Top