KB-630164 | How to use rsync to Synchronize Files

KB-630164 | How to use rsync to Synchronize Files

Purpose

To provide a clear and practical procedure for using the rsync utility to synchronize files and directories between local systems and remote hosts, including push and pull operations, while preserving file attributes and optimizing data transfer.

Scope

This article applies to Linux systems where rsync is used to copy and synchronize files or directories locally or between systems over SSH. It covers basic rsync syntax, commonly used options, source and destination path handling, and local, remote push, and remote pull operations.


How to use rsync to Synchronize Files


rsync (Remote Synchronization) is a fast and efficient tool used to copy and synchronize files or directories between local systems or remote hosts. It optimizes data transfer by copying only the portions of files that have changed since the last synchronization, rather than transferring the entire file each time. This approach reduces bandwidth usage and significantly improves synchronization performance.

The rsync syntax is really simple:

rsync [OPTIONS] SOURCE DESTINATION

Options

The following are some of the most useful options to add to the rsync command:

  • -v or --verbose: the verbose flag will display information about the progress of the task.
  • -a or --archive: equals -rlptgoD. The archive flag sets the most common options instead of setting them individually.

The following are the options set with -a that can also be set one by one:

  • -r or --recursive: recurses into directories. Must be used when you need to copy all the contents inside a directory.
  • -l or --links: copies symlinks as symlinks, does not copy the file to which they point to avoiding loopbacks to other directories.
  • -p or --perms: preserves the permission of the file.
  • -t or --times: preserves the original modification timestamps.
  • -g or --group: preserves the files' groups ownership.
  • -o or --owner: preservers the files' owners.
  • -D: preserves the device files and special files. You can use the options --devices and --specials to accomplish this.

Some other options that can be used are:

  • -progress: displays the progress status per file.
  • --max-size=SIZE: avoids transferring files larger than the specified size.
  • --min-size=SIZE: avoids transferring files smaller than the specified size.
Source and destination paths

It is important to take into consideration how the source and destination paths are specified since a slash can change the behavior.

For example, to copy everything inside a directory called in /home into another one called /new/destination/ the correct rsync syntax would be:

Shell
rsync -a /home/ /new/destination

To copy the directory so that a new folder called home is also created in the destination directory the syntax would be:

Shell
rsync -a /home /new/destination

Note that a single slash after /home will change the end result.

Using rsync with a remote host

When having SSH access to a remote host it is possible to use rsync with a really similar syntax. To copy the contents from the /home directory to the /home/new directory in a host called REMOTE_HOST a push operation is needed. The syntax would be:

Shell
rsync -a /home USER@REMOTE_HOST:/home/new

It is possible to retrieve files from a remote host to your local machine using rsync with a pull operation. The syntax is similar as the mentioned above but now the remote host is the source:


Shell
rsync -a USER@REMOTE_HOST:/home/new /home
       

References

                                                                                              
    • Recent Articles

    • KB 148090 - Install an OS remotely via ASUS IPMI's KVM

      Here's how to install an OS remotely via ASUS IPMI's KVM (Java or HTML5-based remote console): 1. Access the BMC web interface. Connect to the ASUS IPMI/ASMB management LAN port (separate from the server's normal NICs). Browse to ...
    • KB 114035 - Zotac RMA Process

      ZOTAC RMA PROCESS Overview This plan outlines the overall operational support process for ZOTAC hardware supported by Mbuzz, covering warranty validation, technical diagnosis, RMA coordination, replacement and return handling, SLA management, ...
    • Download Log from ASUSTOR NAS

      How to download Log from NAS Purpose: This article will helps support team to guide customer to download Log to share the evidence for component failure. Problem: Customer reports for Storage device not detected. Storage failure. / Storage not ...
    • TeamGroup Memory Warranty & RMA Process

      Purpose To provide a clear and simple process for handling Team Group Memory warranty and RMA claims. Warranty Verification Product model and serial number. Purchase invoice or proof of purchase. Warranty eligibility. Product condition and any signs ...
    • Common Reasons for RMA Rejection

      Purpose This article outlines the most common reasons why RMA requests are rejected. Understanding these reasons helps Technical Support teams reduce claim delays and improve first-time approval rates. Physical Damage RMA requests are rejected when ...
    • Popular Articles

    • CP Plus Camera and NVR Configuration

      NVR Configuration The CP Plus Pro Series of NVRs have been meticulously designed for providing you with upgraded performance and higher recording quality in your IP video surveillance solution. The robust processor that has been inculcated in this ...
    • KB 775235 - Kerberos Authentication – Overview

      What is Kerberos? Kerberos is a secure authentication method used in our Active Directory (AD) environment (mbuzztech.com). It allows users to: Access multiple systems without re-entering passwords (Single Sign-On – SSO) Log in once Where We Use It ...
    • KB 935001 - AMD Ryzen AM4 Motherboard CPU Compatibility

      For the AM4 Platform, AMD has been very generous when it comes to motherboard compatibility. A CPU launched in 2022, like the Ryzen 7 5800X3D, will work with an almost 6-year-old motherboard, like the ASRock X370 Pro, which was launched in early ...
    • KB 532001 - Ubuntu Server 22.04 Installation Hangs on ASUS WRX80e-SAGE Series

      During the installation of Ubuntu Server 22.04 on ASUS WRX80E-SAGE series motherboards, the installation process hangs during the boot phase. The issue is associated with USB disk recognition errors, particularly with devices managed by the XHCI ...
    • KB 686001 - ASUS Server Stress Testing Guide for INTEL and AMD Platforms

      Creating a Bootable USB with Asus Test Tool Step 1: Download Required Files Download Asus Linux Image: Save the Linux image file provided by Asus. Download Memtest Tool: Open a browser, search for "Memtest," and download the free version from the ...