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.
Examples
run from remote computer
$ dd if=/dev/sda | gzip -1 - | ssh user@local dd of=image.gz
run from local computer
$ ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz
Live example
$ ssh skinner "dd if=/dev/sda5 | gzip -1 -" | dd of=image.gz
208782+0 records in
208782+0 records out
106896384 bytes (107 MB) copied, 22.7608 seconds, 4.7 MB/s
116749+1 records in
116749+1 records out
59775805 bytes (60 MB) copied, 23.9154 s, 2.5 MB/s
$ ll | grep image.gz
-rw-rw-r--. 1 saml saml 59775805 May 31 01:03 image.gz
Methods for monitoring?
Login via ssh
in another terminal and ls -l
the file to see what it's size is.
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
Send a "SIGUSR1" signal to dd
and it will print stats. Something like:
$ pkill -USR1 dd
Use dd
's progress switch, status=progress
References
The methods mentioned above for monitoring were originally left via comments by @Ryan & @bladt and myself. I've moved them into the answer to make them more obvious.
ONE
's hard drive to remote computerTWO
's storage), like this:[root@ONE]# dd if=/dev/sda1 | ssh root@TWO
dd of=/root/Public/ONE/sda1.img
409600+0 records in
409600+0 records out
209715200 bytes (210 MB) copied, 0.894929 s, 234 MB/s
Pseudo-terminal will not be allocated because stdin is not a terminal
root@TWO's password:
The problem is that the
– Urhixidur Jul 15 '15 at 13:59/root/Public/ONE/sda1.img
file was created onONE
, not onTWO
as expected. How do I fix this?pv
from the local machine? Thank you. – TCB13 Dec 16 '15 at 15:08status=progress
option. Thus, you do not need to runpkill -USR1 dd
from another terminal anymore. – Till Schäfer Jan 02 '18 at 15:23