Windows usage of Rsync

overview

Rsync is a good free file synchronization software, which can mirror and save the entire directory tree and file system, while maintaining the original file permissions, time, soft and hard links. rsync will copy the entire content during the first synchronization, and only the modified part of the file will be transferred next time. Compression and decompression operations can be performed during data transmission to reduce bandwidth traffic. Support scp, ssh and direct socket connection, support anonymous transmission.

Install and configure the Rsync server

  1. Click the server installation program to install. During the installation process, you will be prompted to enter the user name and password for the server program to run as a service. Can be customized.

  2. After the installation is complete, enter the root directory of the program installation directory, open the configuration file (such as: C:\Program Files\ICW\rsyncd.conf), and enter the configuration.
    insert image description hereinsert image description here

insert image description here
insert image description here

You can also use the default username and password here, it is best to customize one

insert image description here

Modify server-side rsync.conf

default allocation

use chroot = false
strict modes = false
uid = 0  # 0代表不限定用户
hosts allow = * # 所有主机均可访问
gid = 0
log file = rsyncd.log

# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work

[testwin]
path = /cygdrive/d/ftpdata   # 和linux不同的是windows的备份目录前面都要加/cygdrive
ignore errors
read only = false
transfer logging = yes
auth users = testwin_rsync # rsync的虚拟用户
secrets file = etc/rsyncd.password # rsync的密码文件路径 这里如果报错使用全路径 例 /cygdrive/c/Program Files (x86)/ICW/etc/rsync.password

Change setting



use chroot = false

strict modes = false

lock file = rsyncd.lock 

hosts allow = 192.168.1.21

max connections = 5

port = 28950

pid = 0

uid = 0
log file = /cygdrive/f/RsyncLog/rsyncd.log
# Module definitions

# Remember cygwin naming conventions : c:\work becomes /cygdrive/c/work
[data_backup]

path = /cygdrive/f/dataBackup

auth users = dbbackuper

secrets file = /cygdrive/e/Setting/Rsync/rsync_db.ps

read only = no

list = no

transfer logging = yes


The above Windows directory should be written in POSIX style. The default configuration file cygwin does not seem to work, but should be written as cygdrive, such as D:/data, should be written as /cygdrive/d/data.

The above configuration only allows 192.168.1.21 to access, modify here as needed.

strict modes = false does not verify user password,

pid = 0, uid = 0 specifies anonymous access.

auth users: refers to the user name to access data_backup

secrets file: The password file corresponding to the data_backup user name.

Create a new password file: E:\Setting\Rsync\rsync_db.ps. like:

root:root

admin:12345

Password file format: user name: password (root: 12345), one per line, some systems do not support long passwords, and the permissions of another password file are unreadable to other user groups, if the setting is wrong, it may not work. Under Windows, the access rights of the password file must be set correctly, otherwise the user authentication will fail. The permission of the password file E:\Setting\Rsync\rsync_db.ps should be added to the read permission of the user name cwRsyncServer of the Rsycn service running service and set it as the owner of the file. As shown in the figure below:
insert image description here
In the service manager, find the service RsyncServer service and start the service.
If the firewall is enabled, add Tcp port 28950 to allow communication in the firewall rules.
insert image description here

service verification

Open the dos command box, enter telnet 192.168.1.20 28950 (if the telnet server and client are not installed, please find the Telnet client and server in the control panel -> add and remove programs -> open and close windows functions, and check to install ). If the telnet can be successfully connected, and similar text such as @RSYNCD: 30.0 appears, it means that the service starts normally.
insert image description here

Install and configure the Rsync client

Install the Rsync client program until the installation is complete. Refer to the server installation process

test connectivity

The corresponding address and port calculated by telnet on the computer where the Rsync client is located where the Rsync server is located

telnet 192.168.1.20 28950

If @RSYNCD: 30.0 and other similar words appear, it means that the client is connected to the server normally.
insert image description here
Open the Dos command window and enter the bin directory of the Rsync client installation directory, such as: C:\Program Files\cwRsync\bin\. Enter the following command to start the synchronization:

rsync.exe -avz --password-file=rsync.password [email protected]::testwin /cygdrive/f/testwin_rsyncdir

Note: When the client executes, it should be in the bin directory of the client, and there is another way to configure environment variables

cd C:\Program Files\cwRsync\bin\rsync --port=28950 -vzrtopg --progress --delete 192.168.1.20::data_backup /cygwin/f/dataBackup --password-file=/cygdrive/e/Setting/Rsync/rsync_db.ps 

Parameter Description:

–port=28950 #Port-vzrtopg --progress #Display the detailed information of the synchronization process –delete #Delete the data different from the server directory from the client directory to ensure that the data on both sides are completely consistent /cygwin/f/dataBackup #Window
directory F:\dataBackupdata_backup #The
module name defined in the server configuration file rsyncd.conf file 192.168.1.20 #Rsync server IP address

The user who sets up the command file needs to add the read permission of the password file and add it as the file owner. as follows:
insert image description here

Guess you like

Origin blog.csdn.net/cuihwchn/article/details/128617354