1. Home
  2. UNIX Help
  3. Copying and Syncing Files

Copying and Syncing Files

Example to copy from local directory to remote server.

To sync data on local computer to remote server:

rsync -avz full_path_to_source -e "ssh -l username" server_address:full_path_to_destination

To sync data on remote server to local computer:

rsync -avz -e "ssh -l username" server_address:full_path_to_source full_path_to_destination

Example of syncing data from raptor to local computer on my MacOS home directory [Important NOTE: The command will copy the folder “testfolder” and the contents in the testfolder to the dpane home directory):

rsync -avz -e "ssh -l dpane" raptor.ni.cmu.edu:/home/dpane/testfolder /Volumes/HD/dpane/

This example of syncing data from raptor to local computer on my MacOS home directory [Important NOTE: The command below will copy the contents in the “testfolder” to the dpane home directory – adding the trailing “/” on the source cause the command to only copy the contents of the testfolder and not the folder itself.

rsync -avz -e "ssh -l dpane" raptor.ni.cmu.edu:/home/dpane/testfolder/ /Volumes/HD/dpane/



Q:Why should I use rsync instead of scp?
A:When you are transferring a large amount of data, if the transfer is disconnected before completion for any reason, rsync will pick it up where it left off. The command scp doesn’t do this. I recommend scp if you want to transfer one or couple of files or small sized directories. I highly recommend rsync for almost all your syncing and copying needs, especially for multi GB size data.

Q:Does rsync verify files copied between two locations?
A:rsync will always perform checksums to verify that a file was transferred correctly. If the destination file already exists, rsync may skip updating the file if the modification time and size match the source file, but if rsync decides that data need to be transferred, checksums are always used on the data transferred between the sending and receiving rsync processes. This verifies that the data received are the same as the data sent.

Additional information:

There is a lot of documentation online regarding rsync. Here is one with 10 examples….although I DO NOT suggest using the example #8 “Automatically Delete source Files after successful Transfer”: Rsync (Remote Sync): 10 Practical Examples of Rsync Command in Linux

Updated on February 21, 2022

Was this article helpful?

Need Help?
Can't find the answer you're looking for?
Contact NI Support