I wanted to copy everything off the disk and send it over the network. So we can do it with ssh. First zero out the non used space on the running disk to make compressing the image much eaiser. Using the command:

dd if=/dev/zero of=0bits bs=20M; rm 0bits

Then boot knoppix (or any other bootable linux distro like sysrescuecd) from the machine you want to image and give the command:

dd if=/dev/sda | gzip -1 - | ssh user@hostname dd of=image.gz

# example script: (interactive -> will ask you for password if no ssh-public-private-key setup was made prior

vim /backup/system_dd_ssh_to_qnap2.sh; # create script: fill with that content

#!/bin/sh
dd if=/dev/zero of=0bits bs=20M; rm 0bits; # First zero out the non used space on the running disk to make compressing the image much eaiser

dd if=/dev/vda | gzip -1 - | ssh -pPORT SSHUSER@BACKUPSERVERDOMAIN.COM dd of=/hwere/to/backup/$(date '+%Y-%m-%d_TIME_%H-%M-%S').DOMAIN2BACKUP.COM.dd.gz; # backup bit by bit to remote site

# if you manually want to run that script, run it in a screen session, so it keeps running even when you log off
screen -S backup; # start screen session
/backup/system_dd_ssh_to_qnap2.sh; # start script
# Strg+A then D (hit this to detach from screen, now you can savely exit your ssh session, the script will keep on running.

Assuming sda is your hard drive. This sends the local disks data to the remote machine. To restore the image boot knoppix on the machine to restore and pull the image that you created and dump it back with the command:

ssh user@hostname dd if=image.gz | gunzip -1 - | dd of=/dev/sda

This will usually take a few hours so be prepared. A good site that has some info on using ssh this way is here.

https://www.pantz.org/software/dd/drivecopywithsshanddd.html

admin