Tip: save and compress at the same time with dd and gzip

An interesting tip I've found:

To save and compress, the command is as follows (replace xxx with the ID of your disc):



dd if=/dev/xxx conv=sync,noerror bs=4m | gzip -c > xxx.img.gz

To decompress and restore, the command is as follows (replace xxx with the ID of your disc):



gunzip -c xxx.img.gz | dd of=/dev/xxx conv=sync,noerror bs=4m 

For other operating system than *OSX*, use capital M.

Source: [pihomeserver.wordpress.com](http://pihomeserver.wordpress.com/2013/02/07/astuce-sauvegarder-et-compresser-en-meme-temps-avec-dd-et-gzip/)