miércoles, 7 de octubre de 2009

piping partimage using stdout

I don't use partimage a lot and when I use it I tend to use it via it's text interface, but the other day we wanted to send the output of partimage to another computer through the network, and partimaged was not an option.

After looking around a couple of times the final answer came from a changelog file and we ended up with this magical line that I'm writing here and which works really well.

Linea mágica para mandar la salida de partimage por la red usando la salida estándar:

partimage -f3 -d -V0 -B gui=no save /dev/sda1 stdout | nc -w 60 address port

It seems partimage has some kind of problems while doing a restore of a compressed file, so the recipe for that should be something like...

nc -w 60 address port | gunzip | partimage -f3 -B gui=no restore /dev/sda1 stdin

or you can make nc listen as usual.

2 comentarios:

Santiago García Mantiñán dijo...

Just a quick note, if you are going to pipe a partimage to another partimage you may not want to compress, then use -z 0 on the process making the image and you won't need to uncompress on the one restoring it.

Santiago García Mantiñán dijo...

Just one more note, I have just used partimage to restore the mbr and partition table on a loop device, and then restore partition contents. Here is the full recipe:

dd if=/dev/zero of=40G seek=79999999 count=1
losetup --find --show 40G
partimage -f3 -B gui=no restmbr /dev/loop0 backup.pig
partx -v -a /dev/loop0
partimage -f3 -B gui=no restore /dev/loop0p1 backup.pig

One comment I found on this, restoring the mbr without gui can be misleading as there can be several mbr stored on the backup image and we may end up with the wrong one being restored.