Linux rsync incremental Synchronization Method

Source: Internet
Author: User

Linux rsync incremental Synchronization Method

Run rpm-Qa | grep rsync to check whether rsync has been installed.

The following describes the configuration process of rsyns.
1. Configure the server
First, edit/etc/rsyncd. conf as follows:
Uid = Nobody # The user nobody for backup is any user
Gid = Nobody # The backup group nobody is any group
Use chroot = No # Do not use chroot
Max connections = 10 # maximum number of connections
Log File =/var/log/rsyncd. log # Log File

[Rsyncd] # Here is the Authentication Module name
Path =/home/test/# directory for synchronization
Ignore errors # ignore unrelated Io errors
Read Only = yes # Read-Only
List = No # column list not allowed
Anth users = root # authenticated user name
Secrets file =/etc/rsyncd. Secrets # password file storage address

Edit a rsyncd. Secrets password under/etc to store the file.
Format:

Username: the password is shown in figure

Root: xl1100

Finally, start rsync on the server as a daemon.
Command: rsync-daemon
Rsync starts at Port 873.

Ii. Client Configuration
Edit a rsyncd. Secrets password under/etc to store the file.

Run the following command:
Rsync-vzurtopg -- Progress -- delete root@192.168.100.150: rsyncd/home/test -- password-file =/etc/rsync. Secret
Parameter V indicates a detailed prompt
Z indicates Compression
U indicates update only
Topg stores original file attributes such as the master and time parameters.
-- Progress indicates display
-- Delete: if the server deletes this file, the client also deletes the file to ensure true consistency.
Root is the user name
@ 192.168.100.150 is the Server IP Address
: The subsequent rsyncd is the authenticated Module name.
/Home/test is the name of the local directory for backup.
-- Password-file =/etc/rsync. Secret specifies the address where the password is stored.

You can write the script rsync. Sh.
#! /Bin/sh
Rsync-vzrtopg -- Progress -- delete root@192.168.100.150: rsyncd/home/test -- password-file =/etc/rsync. Secret

Then, add the script to the/etc/crontab file to regularly execute updates.

A detailed explanation of the Option parameter is attached.

Rsync Command Parameters

After the rsync server configuration is complete, the next step is to issue the rsync command on the client to back up the files on the server to the client. Rsync is a very powerful tool, and its commands have many special options. The following describes the options one by one.
The Command Format of rsync can be as follows:
Rsync [Option]... SRC dest
Rsync [Option]... SRC [user @] HOST: dest
Rsync [Option]... [user @] HOST: SRC dest
Rsync [Option]... [user @] HOST: SRC dest
Rsync [Option]... SRC [user @] HOST: dest
Rsync [Option]... rsync: // [user @] host [: Port]/src [DEST]
For the preceding six command formats, rsync has six different working modes:
1) copy a local file. This mode is enabled when the SRC and des paths do not contain a single colon ":" separator. For example, rsync-A/data/backup
2) use a remote shell program (such as RSH and SSH) to copy the content of the local machine to the remote machine. This mode is enabled when the DST path address contains a single colon ":" separator. For example, rsync-avz *. c FOO: SRC
3) use a remote shell program (such as RSH and SSH) to copy the contents of the remote machine to the local machine. This mode is enabled when the SRC address path contains a single colon ":" separator. For example, rsync-avz FOO: src/BAR/Data
4) copy files from the remote rsync server to the local machine. This mode is enabled when the SRC path information contains the ":" separator. Such as: rsync-AV root@172.16.78.192: www/databack
5) copy files from the local machine to the remote rsync server. This mode is enabled when the DST path information contains the ":" separator. Such as: rsync-Av/databack root@172.16.78.192: www
6) List of remote machine files. This is similar to rsync transmission, but you only need to omit the local machine information in the command. For example, rsync-V rsync: // 172.16.78.192/WWW
The Rsync parameters are described as follows:
-V, -- verbose detailed mode output
-Q, -- Quiet simplified output mode
-C, -- checksum: enable the verification switch to force file transfer verification
-A, -- Archive mode, indicating that the file is transmitted recursively and all file attributes are kept, equal to-rlptgod.
-R, -- Recursive processes subdirectories in recursive Mode
-R, -- relative uses relative path information
-B, -- backup creates a backup, that is, if the object already has the same file name, rename the old file ~ Filename. You can use the -- suffix option to specify different backup file prefixes.
-- Backup-Dir: backs up files (for example ~ Filename) is stored in the directory.
-Suffix = suffix defines the backup file prefix.
-U, -- Update only performs updates, that is, skipping all files that already exist in DST and whose file time is later than the time to be backed up. (Do not overwrite the updated file)
-L, -- links retains soft links
-L, -- copy-links: process soft links like regular files
-- Copy-unsafe-links: only copies links other than the SRC path directory tree.
-- Safe-links ignores links other than the SRC path directory tree
-H, -- hard-links
-P, -- perms to keep File Permissions
-O, -- owner keeps file owner information
-G, -- group: Keep file group information
-D, -- devices: Keep Device File Information
-T, -- times preserve the file time information
-S, -- sparse performs special processing on sparse files to save DST Space
-N, -- dry-run which files will be transmitted
-W, -- whole-file: Copy files without incremental Detection
-X, -- one-file-system do not span the boundaries of the file system
-B, -- block-size = size indicates the block size used by the algorithm. The default value is 700 bytes.
-E, -- RSH = command specifies that RSH and SSH are used for data synchronization.
-- Rsync-Path = path specifies the path of the rsync command on the remote server
-C, -- CVS-exclude automatically ignores files in the same way as CVS to exclude files that do not want to be transmitted
-- Existing only updates the files that already exist in DST, instead of backing up the new files.
-- Delete: delete the files that are not in the SRC file in DST.
-- Delete-excluded: Delete Files specified by this option at the receiving end.
-- Delete-after: delete after transmission
-- Ignore-errors is deleted when an IO error occurs in a timely manner.
-- Max-delete = num: a maximum of num files can be deleted.
-- Partial retains the files that are not completely transferred for any reason, so as to speed up subsequent re-transmission.
-- Force directory deletion, even if not empty
-- Numeric-IDs does not match the number user and group ID with the user name and group name.
-- Timeout = time IP timeout, in seconds
-I, -- ignore-times do not skip files with the same time and length
-- Size-only: when determining whether to back up a file, only check the file size, regardless of the file time
-- Modify-window = num determines whether the timestamp window of the file is used at the same time. The default value is 0.
-T -- temp-Dir = dir create a temporary file in Dir
-- Compare-Dest = dir: Compare the files in Dir to determine whether to back up data.
-P is equivalent to -- partial
-- Progress displays the backup process
-Z, -- compress compresses backup files during transmission
-- Exclude = pattern specifies to exclude file modes that do not need to be transmitted
-- Include = pattern specifies the file mode to be transmitted without exclusion
-- Exclude-from = file: exclude files in the specified mode in the file.
-- Include-from = file: files with the specified file pattern matching are not excluded.
-- Version: prints version information.
-- Address: bind to a specific address
-- Config = file: specify other configuration files. The default rsyncd. conf file is not used.
-- Port = port specify other rsync service ports
-- Blocking-io: block Io for remote shell
-Stats indicates the transmission status of some files.
-- SS actual transmission process during transmission
-- Log-format = format specifies the log file format
-- Password-file = file get password from File
-- Bwlimit = kbps limits I/O bandwidth, Kbytes per second
-H, -- help: displays help information
AZV is generally used.

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.