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

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...

141 Responses

  1. jobzaaclub says:

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

  2. 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

  3. 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. https://stackoverflow.com/questions/43624832/rsync-compression-and-how-it-works)

  4. 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

    step1:

    # sftp [email protected]
    password
    

    step2:

    # cd /sourcedir
    

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

    # get -Pr 2018-02-26
    bye
    

    step4:

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

    I need to automate this

  5. 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:

      @Donald,

      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'
      
  6. 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.

    Test2:

    # 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
  7. sandeep says:

    Hi,

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

  8. 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.