Sample Header Ad - 728x90

Piping Backups through Compression and Encryption

3 votes
2 answers
2295 views
I am trying to backup a disk image of a local system to a remote system, in a way I can automate by bash script at a later point. Backing up and restoring was going well until I introduced encryption, now I think I'm getting a backup but having difficulty restoring. I'm hoping someone can spot what I'm doing wrong or whether what I'm trying to do isn't possible using these tools. To be more specific I am using: - **dd** - to image the disk - **gzip** - to compress the image - **gpg** - to encrypt the compressed image - **ssh** - to transfer the image to the: - ***Backup Controller*** (192.168.1.10) which will be used to store and retrieve backups on. I will refer to it as *remote* because it is seperate to the *local* system I am aiming to back up. Taking a step back to simplify it (without encryption) and to to show you what **I did have working**: **Backing Up:** dd if=/dev/sda | gzip --best - | ssh user@192.168.1.10 dd of=/home/user/sys1-backup.gz.img This backups up the local drive (/dev/sda) to the remote *Backup Controller* whilst compressing it with a high level of compression. **Restoring Backup:** When restoring I live boot to something like gparted or Turnkey Linux Core and run: ssh user@192.168.1.10 dd if=/home/user/sys1-backup.gz.img | gunzip -d - | sudo dd of=/dev/sda This connects to a remote *Backup Controller*, pipes dd through gunzip to decompress the image and then restores it to the local disk successfully. **That works.** But when I try to introduce encryption (pgp) things fail when restoring. **Backing up with Encryption**: dd if=/dev/sda | gzip --best - | gpg -q --symmetric --cipher-algo AES256 --yes --batch --passphrase MySuperSecurePassword | ssh user@192.168.1.10 dd of=/home/user/servername-disk.gz.gpg To the best of my knowledge I think this part (backing up) is working with encryption. **Restoring with Encryption** - (which I think is failing): ssh user@192.168.1.10 dd if=/home/user/servername-disk.gz.gpg | gpg -q --symmetric --cipher-algo AES256 --yes --batch --passphrase MySuperSecurePassword | gunzip -d - | dd of=/dev/sda Gives the output: gzip: stdin: not in gzip format 0+0 records in 0+0 records out 0 bytes copied, 0.325412 s, 0.0 kB/s gpg: [stdout]: write error: Broken pipe gpg: DBG: deflate: iobuf_write failed gpg: [stdout]: write error: Broken pipe gpg: DBG: deflate: iobuf_write failed gpg: [stdout]: write error: Broken pipe gpg: filter_flush failed on close: Broken pipe I'm new to using gpg and dd on the shell so if anyone can spot my mistake or inform me of limitations of the tools I'm using I would greatly appreciate it!
Asked by user281618 (31 rep)
Aug 8, 2019, 05:10 PM
Last activity: Jul 8, 2024, 04:44 PM