Rsync + Linux client + Windows client Configuration

Source: Internet
Author: User

Rsync + Linux client + Windows client Configuration

Rsync is a very powerful tool. 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.17.5.13: 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.17.5.13: 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.17.5.13/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

Generally, the auz option is used.

On Linux 172.17.5.13

Rpm Installation Method
[Root @ Server_rsync ~] # Rpm-qa | grep rsync
Rsync-3.0.6-4.el5_7.1
By default, rsync is installed on RHEL. You can edit/etc/xinetd. d/rsync and start it with service xinetd restart.
[Root @ Server_rsync ~ ~] # Vim/etc/xinetd. d/rsync
# Default: off

# Description: The rsync server is a good addition to an ftp server, as it \

# Allows crc checksumming etc.

Service rsync

{

Disable = no. yes is changed to no by default.

Socket_type = stream

Wait = no

User = root

Server =/usr/bin/rsync

Server_args = -- daemon

Log_on_failure + = USERID

}
Install rsync in source code:

Go to the official website to download the latest version of http://rsync.samba.org/download.html

[Root @ Server_rsync ~] # Tar-xvzf rsync-3.1.1.tar.gz-C/usr/local
[Root @ Server_rsync ~] # Cd/usr/local/rsync-3.1.1/
[Root @ Server_rsync ~] # Configure; make install

 

The source code is successfully installed, but the method for starting the server is different. The configuration file is the same as the method for starting the server:

 

/Usr/local/rsync-3.1.1/rsync -- daemon

The configuration file does not have/etc/rsync. conf by default when you create an rsync server.
[Root @ Server_rsync ~] # Vim/etc/rsyncd. conf

Motd file =/etc/rsyncd. motd welcome information, you can leave it empty
Pid file =/var/run/rsyncd. pid
Lock file =/var/run/rsync. lock
Log file =/var/log/rsyncd. log
Port = 873 port can be left empty. The default port is port 873. You can change it to another port.
Uid = root can be nobody
Gid = root
Hosts allow = 192.168.0.0./16,172.17 .0.0/16
Hosts deny = *
Max connections = 10
# The above section is global configuration. The following modules can have multiple
[Files] Module name, named by yourself
Path =/backup/ftptap2delcom/
Comment = rsync ftp. This is the description of the object to be shared.
Ignore errors
Read only = yes
List = no
Auth users = rsync_test the account used for Synchronous verification. This user has no relationship with/etc/password.
Secrets file =/etc/rsyncd_pwd specify the authentication file and then create the authentication file
The configuration file ends. The following is the password change file.
[Root @ Server_rsync ~] # Vim/etc/rsyncd_pwd
Rsync_test: 2014?

The format of/etc/rsyncd_pwd is User name: password. Note that this is not a system user, but a rsync_test user.
[Root @ Server_rsync ~] # Chmod 600/etc/rsync. passwd can only be readable by the owner; otherwise, an error is returned.
[Root @ Server_rsync ~] # Service xinetd start
Starting xinetd: [OK]

Check rsync Process
[Root @ Server_rsync ~] # Netstat-anp | grep 873
Tcp 0 0 0.0.0.0: 873 0.0.0.0: * LISTEN 3169/xinetd

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.
Test on the Linux client:
The client only needs to create a password file, and the file name can be named by itself.
[Root @ Client_rsync ~] # Touch/etc/pwd; vim/etc/pwd
[Root @ Client_rsync ~] #2014? The client only needs a password, but does not need a user name: Password
[Root @ Client_rsync ~] # Chmod 600/etc/pwd can only be readable by the owner; otherwise, an error is reported.
[Root @ Client_rsync ~] # Rsync-auz -- delete-password-file =/etc/pwd rsync_test@172.17.5.13: files/backup_client/ftptap2delcom
Grouping file list... rsync: readlink "/install. log" (in jason) failed: Permission denied (13)
Rsync: readlink "/install. log. syslog" (in jason) failed: Permission denied (13)
Rsync: readlink "/anaconda-ks.cfg" (in jason) failed: Permission denied (13)
......
Check whether the client/backup_client/ftptap2delcom file is synchronized with the server/backup/ftptap2delcom file. Synchronization is OK
Scheduled
Rsync-auz -- delete-password-file =/etc/pwd rsync_test@172.17.5.13: files/backup_client/ftptap2delcom this statement is written to cron for regular synchronization.

Windows Client
Download Windows cwrsync from the official website
For: http://rsync.samba.org/download.html
After downloading the file, decompress it to drive C and rename it rsync. Create the password file PWD in the corresponding directory:

You can run the following command in CMD:
C: \ rsync \ rsync.exe -- port = 873-avz -- password-file =/cygdrive/c/rsync/pwd rsync_test@172.17.5.13: files/cygdrive/d/ftptap2delcom
In this command, cygdrive/d/is the specified windows d Drive, And/cygdrive/D/ftptap2delcom is equivalent to d:/ftptap2delcom
Scheduled operation
You can use a bat script to run the scheduled tasks in windows:
Script Name: rsync. bat
Content:
@ Echo off
@ C: \ rsync \ rsync.exe -- port = 873-avz -- password-file =/cygdrive/c/rsync/pwd rsyn c_test@172.17.5.13: files/cygdrive/d/ftptap2delcom

Common Errors
If -- password-file is not specified, you must enter the password interactively before synchronization.
You can create a password file on the client.

[Root @ station204 ~] # Vim/etc/pwd

123456 # As long as the password is OK, do not use the user name.

[Root @ station204 ~] # Chmod 600/etc/pwd # Only the owner can read data; otherwise, an error is reported.
[Root @ station204 ~] # Rsync-auz -- delete-password-file =/etc/pwd rsync_test@172.17.5.13: files/backup_client/ftptap2delcom

Rsync + inotify implement real-time synchronization and backup of Git data

Rsync for file backup Synchronization

Rsync synchronizes two servers

Remote synchronization of Rsync in CentOS 6.5

Use Rsync in Ubuntu Linux for data backup and Synchronization

Linux uses the Rsync client to synchronize directories with the server for backup

Rsync details: click here
Rsync: click here

This article permanently updates the link address:

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.