Search code examples
pipebackuprestore

backup and restore e2image how do I properly pipe the output from lzop?


I have for the longest time used dd with gzip as my backup solution. I have been experimenting with faster ways of backing up.

on my Ubuntu 18.04 system, so far this was the quickest for creating a compressed backup image of an ext2/3/4 partition:

sudo e2image -ra -p /dev/sda1 - | lzop -1 > `date +%F`.e2image2.lzo

when performing the above command sda1 is not mounted, I am booted into sdb1. For anyone interested in that topic, i just worked it out here: https://askubuntu.com/questions/1063085/

Now that I have the backup image, 2018-08-08.e2image.lzo, I need a way to restore it to /dev/sda1

The lzop man page gives this example for tar:

lzop -dc some-file.tar.lzo | tar -xvf -

I am trying to adapt that example by piping the output of the lzop decompression example to e2image:

lzop -dc 2018-08-08.e2image.lzo | e2image -ra -p - /dev/sda1

e2image 1.44.1 (24-Mar-2018)
e2image: No such file or directory while trying to open -

e2image does not seem to like the way I specified the input file as "-" which I thought was the proper way of using standard input when using a pipe.

Any help figuring out the problem here appreciated.

I would have also used the tags e2image and lzop, but I do not have enough reputation to add those new tags.


Solution

  • You can just pipe the output from lzop to dd; that's probably the simplest and most consistent way.

    If you know that the output device has been pre-initialized to all zero's, you can use the make-sparse.c program found in the contrib directory of e2fsprogs. The make-sparse program will skip writing blocks which are all zero's, and lseek to the offset where there is a non-zero block, and write only the non-zero blocks. If there are data files which have all zero blocks, and the block device is not pre-initialized to all zeros, then using make-sparse to write to the block device will result in the data file getting corrupted. The make-space progam is designed for use when taking the e2image file and writing it to a sparse file.

    But the simplest way is to just use dd:

    lzop -dc 2018-08-08.e2image.lzo | dd of=/dev/sda1 bs=4k