Rsync Remote Data Synchronization tools

Source: Internet
Author: User
Tags syslog

Rsync Remote Data Synchronization tools


Rysnc (Remote synchronize) is installed in/usr/bin by default in centos. In addition, rysnc has a corresponding version on Windows. Home address: http://rsync.samba.org/

 

Rysnc command usage:( Option-parameter, user-user, HOST-IP address, Src-copy source location, DEST-copy target location)
Shell pull: rsync [Option] [user @] HOST: SRC [DEST]
Rsync pull: rsync [Option] [user @] HOST: [module] [DEST]
Shell push: rsync [Option] SRC [user @] HOST: dest
Rsync push: rsync [Option] SRC [user @] HOST: dest

 

Common rsync commands
-A Recursively transfers a file and maintains its attributes.-rlptgod does not contain-H.
-R sub-directories are processed in recursive Mode
-L maintain the symbolic link file
-H: Keep the hard link file
-P: Keep File Permissions
-T preserve file time information
-G: keep the file owner group information.
-O: retain the owner user information of the file
-D. Keep the device files and special files.
-Z compresses files during File Transfer
-- Exclude = pattern specifies to exclude a file match mode that does not need to be transmitted
-- Exclude-from = File Read exclusion rules from File
-- Include = pattern specifies the file matching mode to be transmitted
-- Include-from = file: Read matching rules from File
-- Copy-unsafe-links: copy the link file pointing to a directory other than the copy Source Path.
-- Safe-links ignores link files that point to a directory other than the copy Source Path (default)
-- Existing only updates the files that already exist on the acceptor without copying the newly created files.
-- Ignore-existing ignores the files that already exist on the acceptor and only copies the newly created files.
-B. Back up the old files in the target directory when there is a change.
-- Use Backup-Dir = dir in combination with-B to specify the backup path
-- Link-Dest = dir: Creates a hard link file in the specified path when the file is not changed.
-- Delete: delete the file that exists at the receiving end and does not exist at the storage end.
-- Delete-before: the acceptor deletes the data before transmission (default)
-- Delete-during acceptor deletes the acceptor during transmission
-- Delete-after acceptor deletes data after transmission
-- Delete-excluded acceptor deletes data during transmission
-- E, -- RSH = command specifies the shell program that replaces RSH
-- Ignore-erros must be deleted even if an I/O error occurs.
-- Partial retains files that are not completely transferred for some reason to accelerate subsequent re-transmission.
-- Progress displays the transmission process during transmission
-P is equivalent to-partial-progress.
-- Delay-Updates: Save the file being updated .~ TMP ~ Temporary directory. Update the target file after transmission.
-V, -- verbose detailed output mode
-Q, -- Quiet simplified output mode
-H, -- human-readable output file size
-N, -- dry-run: displays the files to be transmitted.
-- List-only: Only List objects without copying
-- Rsync-Path = Program specifies the path of the rsync command on the remote server
-- Password-file = file: Specifies the password to be read from the file to avoid entering the password in the terminal.
-4,-6 Use IPv4 or IPv6
-- Version: prints version information.
-- Help: displays help group information

 

 

Note: If you run the rsync command as a normal user, the owner of the synchronized file will be changed to the normal user identity; if you run the rsync command as a superuser, the file attributes remain unchanged. If-Tg is specified but no user or group is specified for the target computer, the copied files are classified into group 501 of 501 users.

 

 

Rsync Service
Start rsync: # vi/etc/xinetd. d/rsync and change disable = yes to no
Service rsync
{
Disable = No
Socket_type = stream
Wait = No
User = root
Server =/usr/bin/rsync
Server_args = -- daemon
Log_on_failure + = userid
}

 

 

 

Rsync Configuration
The rsync server can run independently or by xinetd. By default, centos runs with xinetd and listens to port 873 by default. You need to create the rsync configuration file VI/etc/rsyncd. conf
All configuration lines other than the [module] in the file are global parameters. You can also define the module parameters in the global parameters section. The main function of the module parameters defines the directory to be synchronized, you can define multiple modules as needed.
Secrets file =/etc/rsyncd. Secrets
Read Only = Yes
List = Yes
Uid = nobody
Gid = nobody
Max connections = 10
PID file =/var/run/rsyncd. PID
Lock file =/var/run/rsync. Lock
Log File =/var/log/rsyncd. Log

[Module] -- aliases can be used to create multiple units
Comment = tranlate nginx from 151
Path =/usr/local/www/supe/
Auth users = root
Uid = root
Gid = root
Secrets file =/etc/rsyncd. Secrets
Read Only = No

 

Global Parameters
The IP address of the server running. This parameter is ignored when xinetd runs.
Port: Specifies the port number of the rsync daemon listener (873 by default ). This parameter is ignored when xinetd runs.
Motd file specifies a message file. When the client connects to the server, the file content is displayed to the client.
PID file rsync daemon writes its PID to the specified file
Log File specifies the log file of the daemon, instead of sending the log to syslog.
Syslog facility specifies the message level when a log message is sent to syslog.
Socket options custom TCP options
 

Basic module Parameters
Path specifies the synchronization path of the current module on the rsync server. You must specify
Comment specifies a description for the module

Control Module Parameters
Use is set to true by default. Before transferring a file, chroot is directed to the directory specified by the path parameter. This provides additional security protection. However, the root permission is required, in addition, you cannot back up the directory file pointed to by the symbolic link pointing to the external path.
UID indicates the UID specified for this module to transfer files.
GID specifies the specified GID file for this module
Max connections limits the maximum number of concurrent connections to protect the server. If the limit is exceeded, the system prompts you to operate later.
Lock file specifies the lock file that supports the max connections parameter. The default value is/etc/run/rsyncd. Lock.
List indicates whether the module is listed when the customer requests to list available modules (true by default. If false, you can create hidden modules.
Read Only indicates whether the client may upload files. By default, the file cannot be uploaded. If this parameter is set to false and the server directory has read and write permissions, upload is allowed.
Write only indicates whether the client may upload files. By default, the file cannot be downloaded. If this parameter is set to false and the server directory has read and write permissions, the download is allowed.
Ignore errors specifies whether the rsync server ignores I/O errors when running the delete operation
Ignore nonreadable specifies that the rysnc server ignores users who do not have file access permissions.
Timeout: sets the connection timeout in seconds.
Dont compress tells rysnc that the files do not need to be compressed before transmission. By default, the compressed packages are not compressed.
Refuse options defines a list of Command Options that customers are not allowed to use for this module.

File filter module Parameters
Exclude specifies multiple excluded files or directories, separated by Spaces
Exclude from read exclusion rules from specified files
Include specifies that multiple files or directories are copied, which are separated by spaces.
Include from read inclusion rules from a specified file

User Authentication Module Parameters
Auth users indicates that the user is allowed to connect to this module.
Secrets file specifies a password authentication File
Strict modes specifies whether to check the password file permission. The Rsync authentication Password File Permission must be 600

Access Control Parameters
Hosts allow specifies which IP addresses can access this module
Which IP addresses specified by hosts deny cannot access this module?

Set to start rsync with the System
# Chkconfig rsync on

 

 

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.