Thursday, August 17, 2017

Clone HDD Remotely

If your intent is to backup a remote computer's HDD A via SSH to a single file that's on your local computer's HDD, you could do one of the following.

Find the hard drive to backup. Notice that the hard drive is only the letters and not the number since the number is the partitions.
df -h
Run from remote computer
sudo dd if=/dev/sda | gzip -1 - | ssh user@local dd of=image.gz
Run from local computer
sudo ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz

Methods for monitoring?

  1. Login via ssh in another terminal and ls -l the file to see what it's size is.
  2. You can use pv to monitor the progress of a large dd operation, for instance, for the remote example above, you can do:
    $ dd if=/dev/sda | gzip -1 - | pv | ssh user@local dd of=image.gz
    
  3. Send a "SIGUSR1" signal to dd and it will print stats. Something like:
    $ pkill -USR1 dd