Rsync (Remote Sync): 10 Practical Examples of Rsync Command in Linux

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Tarunika Shrivastava

I am a linux server admin and love to play with Linux and all other distributions of it. I am working as System Engineer with a Web Hosting Company.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

149 Responses

  1. amim says:

    What about daemon mode?

    Nobody explains, besides running under inetd and configuration files, how to actually use with source and destination.

  2. Clay Crash says:

    I’d like to copy an external hard drive (iTunes Library, etc.) to another external hard drive (to serve as a back-up) when they are both connected to my MacBook Pro. I am not a programmer and have no experience or understanding of the codes and commands you all may take for granted.

    A friend told me about rsync and I have done a little exploring online. It would be so helpful if someone would provide the script that I could copy-and-paste into the Terminal window.

  3. jobzaaclub says:

    How to auto rsync when i upload to master server complete.

  4. Leslie Satenstein says:

    What about rsync and hidden files in one pass. Is this possible?

    I used rsync for ./Leslie/* and then for ./Leslie/\,*

    I did not notice anywhere where Icould combine the two rsync commands to save one pass

    • PAVEL PETROV says:

      I think you might to enter both arguments one after one as it can be done with cp or mv tools but only difference that it must be put in brackets like this: './Leslie/* ./Leslie/.*'.

  5. Benjamin Gathmann says:

    I want to point out that you should definitely NOT use the -z option (=compress) when using rsync for a local transfer.

    This will unnecessarily slow things down.

    (check out e.g.

  6. ravikiran dasari says:

    Hi, its good stuff, I need to automate following job process, I need to do same for every one hour, I feel its better to make use of rsync, but how to use this for my application? I can not do any thing at remote server side. i got sftp access only, generally I am doing following things manually


    # sftp [email protected]


    # cd /sourcedir

    step3:in above directory every day one directory will create, in this directory some files are dropping.

    # get -Pr 2018-02-26


    # hadoop fs -put -f 2018-02-26 /destination

    I need to automate this

  7. DonaldShimoda says:

    I need to rsync two machines losing connectivity as an standard. I mean they only see on a short period of time and i can’t know when that happens. have rsync some exit code? Or must i just use an script and try one and another time until they see? Any timeout setup to allow the search to bee short?

    Best regards.

    • Ravi Saive says:


      If it’s a connection timeout because of SSH server is slow to respond, you can set the timeout option while running rsync as shown.

      # rsync -e 'ssh -o ConnectTimeout=120'
  8. Mashkoor Qadir says:

    Hello friends,

    Can any one tell me how to keep update my backup machine.

    The problem is here.

    Source to destination synchronization need to be 100% accurate. Actually I have 2 servers that I need to be sync (100% copy of each other). I have tested it in the following way.

    rsyncdemo dir on both servers that I need to synchronize that contains further sub folders and files.
    Test 1:

    # rsync -uvr -e ssh  /rsyncdemo [email protected]:/rsyncdemo 

    It copies all data successfully no issues. but problem is that if I delete a file or folder on the source machine it do not delete it from the destination.


    # rsync -uvr --delete -e ssh  /rsyncdemo [email protected]:/rsyncdemo 
    It checks on both servers if I deliberately delete a file from the source. The rsync command check it on destination and copy it back to source machine.
    I want to keep the destination machine up to date according to the source machine. 
    How to block/restrict the rsync no to copy any file or folder from the destination to source.
    Thanks in Advance
  9. sandeep says:


    I am trying to use the rsync with --delete (step :6). But unable to remove the files in the destination.

  10. Raj says:

    How do I use rsync to copy incremental files from window server to my linux server. Need to use sftp.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.