Rsync usage in Linux

Source: Internet
Author: User
Tags rsync rsync usage

I. Rsync Overview

Rsync is a data image backup tool in Unix-like systems. It can be seen from the software name-remotesync. Rsync is a file synchronization and data transmission tool in Linux. It uses the "rsync" algorithm to synchronize files between a client and a remote file server, you can also back up data from one partition to another in the local system. If data transmission is interrupted during the backup process, you can continue to transfer the inconsistent parts after recovery. Rsync supports full or Incremental backup. Its main features include:

1. images can be used to save the entire directory tree and file system;

2. It is easy to maintain the permissions, time, and soft links of the original file. The installation can be completed without special permissions;

3. data can be incrementally synchronized, and the file transmission efficiency is high, so the synchronization time is short;

4. You can use RCP, ssh, and other methods to transmit files. Of course, you can also use a direct socket connection;

5. Anonymous transmission is supported to facilitate website images;

6. Encrypted data transmission ensures data security;

Ii. Image directory and content

Rsync-AV duying/tmp/test

View the/tmp/test directory. We can see that this command is to test the Directory and content of the duying folder to the current directory.

Rsync-avduying // tmp/test Note: The symbol "/" is more than the previous command.

View the/tmp/test directory again. We found that there is no duying directory, but we only saw the contents in the directory.

Iii. Incremental backup of local files

Rsync-avzrtopgl -- Progress/src/DST

-V is "-- verbose", that is, the detailed mode output;-Z indicates "-- compress", that is, the data is compressed during transmission;

-R indicates "-- Recursive", that is, the subdirectory is processed in recursive mode;-T indicates "-- time", that is, the file time information is maintained;

-O indicates "owner", which is used to keep the file owner information;-P indicates "perms", which is used to keep the file permission;

-G is a "group" to keep the group information of the file;

-- Progress is used to display the data image synchronization process;

Iv. synchronous backup file for images

Rsync-avzrtopg -- Progress -- delete/src/DST

-- The delete option specifies that the data image is synchronized Based on the rsync server, that is, the directory on the rsync server must be exactly the same as that on the client;

The -- exclude option is used to exclude file types that do not need to be transferred;

5. Set a timed backup policy

Crontab-e

30 3 * rsync-avzrtopg -- Progress -- delete -- exclude "* access *"

-- Exclude "* debug *"/src/DST

 

If the file is large, you can use nohup to place the process to the background for execution.

Nohup rsync-avzrtopgl -- Progress/data/opt/data2/>/var/log/$ (date + % Y % m % d). Mail. log &

 

Vi. Advantages and Disadvantages of rsync

Compared with traditional CP and tar backup methods, rsync has the advantages of high security, fast backup, and support for Incremental backup. Rsync can meet the requirements for data backup with low real-time requirements, for example, regularly back up the data on the file server to the remote server, and regularly perform data mirroring on the local disk.

However, as the system grows, the disadvantages of rsync are gradually exposed. First, when Rsync is used for data synchronization, it needs to scan all files for comparison, and then perform differential transmission. If the file is large, it is very time-consuming to scan the file, and the changed file is usually a small part, so Rsync is very inefficient. Secondly, rsync cannot monitor and synchronize data in real time. Although it can trigger Synchronization Through the Linux daemon, there must be a time difference between the two triggering actions, data on the server and client may be inconsistent.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.