Rsync Command
    • PDF

    Rsync Command

    • PDF

    Article Summary

    Available in Classic and VPC

    Rsync is a utility used for synchronizing and backing up files and directories between remote or local systems.

    Caution

    To synchronize data using rsync, the network connection status must remain stable. When the network connection status from Source VM to Target VM is unstable, data transfer may fail. To prevent data transfer failures, see the following and check the network connection beforehand.

    • Set the inbound and outbound rules for IP band, port, and protocol needed in the ACG and the Network ACL to allow the rsync traffic between the target VM and the source VM.
    • When external communication is needed in the VPC environment, check if the following conditions are satisfied.
      • Public subnet: IGW is configured and a public IP is assigned
      • Private subnet: NAT Gateway is configured
    • To copy a large amount of data, you need a sufficient network bandwidth. If the network bandwidth between the Target VM and the Source VM is not sufficient, the data transfer speed may be lower. To prevent this, add the --bwlimit option to the rsync command and set the bandwidth limits.
    Note

    When you synchronize data using rsync, an error may occur, so back up in advance to prevent such a problem.

    The following describes how to synchronize data between VMs using rsync.

    1. Check if the rsync package is installed in the source VM and the target VM.

      • If the rsync package is installed, the version information is output as follows:
        # rsync --version
        rsync  version 3.1.3  protocol version 31
        Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others.
        Web site: http://rsync.samba.org/
        Capabilities:
           64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
           socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
          append, ACLs, xattrs, iconv, symtimes, prealloc
        
        rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
        are welcome to redistribute it under certain conditions.  See the GNU
        General Public Licence for details.
        
    2. If the rsync package is not installed, install it by entering the appropriate command for your OS.

      • CentOS/Rocky Linux
        # yum install rsync
        
      • Ubuntu
        # apt-get install rsync
        
    3. Before you copy data using rsync, check the port settings of the target VM.

      Note

      The rsync connection may be blocked in accordance with the settings of the firewall, so you must check if the needed port is open and change the firewall settings as needed.

      • Rsync uses the TCP Port 873 for communication by default. When connecting to a remote host, check if Port 873 is blocked by firewall or network limits.
        ## telnet command
        # telnet [IP_ADDRESS] 873
        
        ## nmap command
        # nmap -p 873 [IP_ADDRESS]
        
      • If you need to use another port for rsync communication, you can designate the relevant remote shell command by using the -e option.
        <example> Command using Port 2222
        # rsync -e 'ssh -p 2222' /source_dir username@destination:/destination_dir
        
    4. Run the rsync command in the source VM to transfer data.

      • You can adjust the option of command as needed to optimize the data transfer.

      • <example> Command for synchronizing data

        # rsync -avz --progress --bwlimit=10000 /source_dir username@destination:/destination_dir
        
        • /source_dir: path to the data you want to synchronize
        • username: user name used to log in to the target server
        • destination: IP address or domain name of the target server
        • The options used in the example are as follows:
          • -a: preserves all file properties using the archive mode
          • -v: displays detailed output
          • -z: uses zip and reduces transfer time
          • --process: displays transfer progress
          • --bwlimit: sets the bandwidth limits when copying or synchronizing files
            • In the example, the maximum bandwidth that the rsync can use is limited to 10,000 KB/s.
          • /source_dir: source directory to transfer
          • username@destination:/destination_dir: IP address or host name, user name, and target directory path of the target VM to which data is transferred
    5. While rsync is copying data to the target VM, monitor the progress.

      • When the copying is completed, you can check the new data synchronized in the target VM.

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.