How to use rsync to copy files from one computer to another.

Posted: July 16, 2014. At: 5:42 PM. This was 3 years ago. Post ID: 7524

This is an example where I am using the rsync command to copy files from one computer to another.

homer@deusexmachina ~ $ rsync -avz -e "ssh -p 443" homer@192.168.100.4:/home/homer/Desktop/ /home/homer/Videos
The authenticity of host '[192.168.100.4]:443 ([192.168.100.4]:443)' can't be established.
ECDSA key fingerprint is ############################################.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.100.4]:443' (ECDSA) to the list of known hosts.
LMDE MATE [email protected]'s password: 
receiving incremental file list
./
Screenshot-1.png
Screenshot-2.png
Screenshot-3.png
Screenshot-4.png
Screenshot.png
note.txt
om mani padme hum.txt
 
sent 160 bytes  received 6,162,675 bytes  821,711.33 bytes/sec
total size is 6,172,665  speedup is 1.00

This is another example using cygwin to connect to my Linux Mint Debian Edition server. I am using port 443 to connect to my Linux machine.

Administrator@WIN-EM8GK0ROU41 ~
$ rsync -avz -e "ssh -p 443" homer@192.168.100.4:/home/homer/Desktop/ /home/Administrator/Documents
The authenticity of host '[192.168.100.4]:443 ([192.168.100.4]:443)' can't be established.
ECDSA key fingerprint is ################################################.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.100.4]:443' (ECDSA) to the list of known hosts.
LMDE MATE [email protected]'s password:
receiving incremental file list
./
Screenshot-1.png
Screenshot-2.png
Screenshot-3.png
Screenshot-4.png
Screenshot.png
note.txt
om mani padme hum.txt
 
sent 163 bytes  received 6162630 bytes  648715.05 bytes/sec
total size is 6172665  speedup is 1.00

As you can see; this is a very useful command for copying files from one machine to another.

Use rsync this way to get a list of files from the server.

Administrator@WIN-EM8GK0ROU41 ~
$ rsync -avz -e "ssh -p 443" homer@192.168.100.4:/home/homer/Desktop
LMDE MATE Editionhomer@192.168.100.4's password:
receiving incremental file list
drwxr-xr-x       4096 2014/07/09 21:12:11 Desktop
-rw-r--r--    1471271 2014/07/06 13:20:28 Desktop/Screenshot-1.png
-rw-r--r--    1720427 2014/07/07 12:36:19 Desktop/Screenshot-2.png
-rw-r--r--    1722143 2014/07/07 12:36:25 Desktop/Screenshot-3.png
-rw-r--r--    1002758 2014/07/07 15:10:17 Desktop/Screenshot-4.png
-rw-r--r--     256022 2014/07/05 22:01:48 Desktop/Screenshot.png
-rw-r--r--         25 2014/07/05 22:24:43 Desktop/note.txt
-rw-r--r--         19 2014/07/09 21:12:11 Desktop/om mani padme hum.txt
 
sent 24 bytes  received 212 bytes  42.91 bytes/sec
total size is 6172665  speedup is 26155.36

This is how to return a file list from the server using rsync.

Administrator@WIN-EM8GK0ROU41 ~
$ rsync -avz -e "ssh -p 443" homer@192.168.100.4:/home/homer/Desktop | awk '{ print $NF }'
LMDE MATE Editionhomer@192.168.100.4's password:
list
Desktop
Desktop/Screenshot-1.png
Desktop/Screenshot-2.png
Desktop/Screenshot-3.png
Desktop/Screenshot-4.png
Desktop/Screenshot.png
Desktop/note.txt
hum.txt
 
bytes/sec
25719.44

This is how to return a more verbose output.

Administrator@WIN-EM8GK0ROU41 ~
$ rsync -avz -e "ssh -p 443" homer@192.168.100.4:/home/homer/Desktop | awk '{ print $F }'
LMDE MATE Editionhomer@192.168.100.4's password:
receiving incremental file list
drwxr-xr-x       4096 2014/07/09 21:12:11 Desktop
-rw-r--r--    1471271 2014/07/06 13:20:28 Desktop/Screenshot-1.png
-rw-r--r--    1720427 2014/07/07 12:36:19 Desktop/Screenshot-2.png
-rw-r--r--    1722143 2014/07/07 12:36:25 Desktop/Screenshot-3.png
-rw-r--r--    1002758 2014/07/07 15:10:17 Desktop/Screenshot-4.png
-rw-r--r--     256022 2014/07/05 22:01:48 Desktop/Screenshot.png
-rw-r--r--         25 2014/07/05 22:24:43 Desktop/note.txt
-rw-r--r--         19 2014/07/09 21:12:11 Desktop/om mani padme hum.txt
 
sent 24 bytes  received 212 bytes  52.44 bytes/sec
total size is 6172665  speedup is 26155.36
      1 [waitproc] -bash 2972 sig_send: error sending signal 20, pipe handle 0xB9C, nb 132, packsize 0, Win32 error 109

No comments have been made. Use this form to start the conversation :)

Leave a Reply