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. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  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.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

110 Responses

  1. Br. Bill says:

    When rsyncing from local to local, compressing only slows it down. Skip the -z option if you’re backing a local disk up to a local disk, because it’s just reading the whole file, compressing it, decompressing it, and writing the whole file. No need for the compression middleman if the sync isn’t over a network.

    • Ravi Saive says:

      @Bill,

      Thanks for the tip, didn’t know this, actually I never used rsync for local backups, I always used to sync remote servers with local, anyway thanks hope this will help other users who used to backup files locally..

  2. Raja says:

    Hi Ravi,

    I have tried as per your suggestion but it’s not working as my requirement. still, am able to copy the timestamp which has presented on the source .

  3. Raja says:

    Thanks for your reply.

    As per your above command, it doesn’t meet my requirement. I guess ‘n’ argument is dry-run (not do any file transfers, instead it will just report the actions it would have taken.)
    Please help me on this and I need only copy changed folders in source and don’t want copy the time stamp which is not copied and changed on destination.

  4. Raja says:

    Hi,

    With Rsync command I want only copy/sync changed files/folder to the destination folder. I had some issue with Rsync-like whenever am executing the Rsync command am copied along with the time stamp as well.

    For example, my destination folder ‘Linux’ had updated on 30th June and in my source folder there is no update info for the Linux folder, but when am performing the Rsync command my destination Linux folder time stamp has been updated with source folder time stamp. I don’t want to copy the timestamp as well. please suggest me on this and please glance on below command which I have used.

    rsync -avh /source/Linux/ /destination/Linux/

    • Ravi Saive says:

      @Raja,

      You can use following command to only sync new or changed files over rsync to destination folder:

      # rsync -uan /source/Linux/ /destination/Linux/
      
      • Raja says:

        Thanks for your reply.

        As per your above command, it does not work because the ‘n’ argument tells the dry-run (not do any file transfers, instead, it will just report the actions it would have taken)
        For your info am doing this Rsync with two directories present on the same server. Please help me on this.

        Simply, need to copy only latest changed files/folders from source to destination.(don’t want to copy the timestamp which has not changed in source)

        • Ravi Saive says:

          @Raja,

          Yes, the -n option is used to check the files, and once you confirm that the files are listed correctly on the dry-run, remove the -n option and run:

          # rsync -ua /source/Linux/ /destination/Linux/
          
          • Raja says:

            Hi Ravi,

            I have tried as per your suggestion but it’s not working as my requirement. still, am able to copy the timestamp which has presented on the source .

      • Raja says:

        Thanks for your reply.

        As per your above command, it doesn’t meet my requirement. I guess ‘n’ argument is dry-run (not do any file transfers, instead it will just report the actions it would have taken.)
        Please help me on this and I need only copy changed folders in source and don’t want copy the time stamp which is not copied and changed on destination.

  5. Gaurav Parashar says:

    Hi Ravi,
    You mentioned in one of your examples that you could transfer the contents from source to destination securely over ssh when you use the “-e” option and specify ssh. May i know that over what protocols is the transfer done when not using ssh option?

    • Ravi Saive says:

      @Gaurav,

      Yes, I do mentioned that you can transfer files from source to another securely using SSH, but still it all depends on which protocol you configured under sshd_config file, I suggest to use Protocol 2 for more better security in SSH configuration file..

  6. daniel raiche says:

    rsync works great but how do I get it to keep using the entire network bandwidth for really large files, 1tb+? I’m hitting 200mbs a sec over a 10gb ethernet connection in the beginning but sometimes it slows to 20mbs for no apparent reason and stays there.

    Is there a way to have it check or do an ack reset to re-negotiate the link speed through the switch?

    • Ravi Saive says:

      @Daniel,

      The slowness happens because of file encryption during transfer files over SSH, if you have that much of large data, you can reduce the encryption level or use other alternative tool like parsync (a rsync wrapper for larger data transfer).

Got something to say? Join the discussion.

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

Join Over 150K+ Linux Users
  1. 100,756
  2. 5,113
  3. 36,418

Enter your email to get latest Linux Howto's