Some time ago I wrote an article on using rsync for batch update in Linux. I can see that there are still a lot of windows servers in online gaming companies. Today I will talk about the batch update method in windows, using cwRsync to synchronize data in windows
I. System Environment
Windows 2003 R2 sp2
Update source server: 10.8.5.240
Target Server: 10.8.5.2 10.8.5.3 ......
Server: cwRsyncServer_4.1.0_Installer
Client: cwRsync_4.1.0_Installer
Ii. Update the installation configuration of the source server (rsync server)
1、double-click cwrsyncserver_4.1.0_installer.exe and proceed to the next step. By default, the server that installs cwRsync has an administrator account SvcCWRSYNC, which can be modified on its own.
After the installation is complete, you can see the corresponding cwRsync service in the "service". After the installation is complete, you need to manually start the service.
2. Modify the rsyncd. conf configuration file (C: \ Program Files \ ICW \ rsyncd. conf)
- Use chroot = false # Do not use chroot
- Strict modes = false # static mode
- Hosts allow = * # All IP addresses are allowed
- Log file = rsyncd. log # log file name. You can specify the path
- Pid file = rsyncd. pid
- Port = 8173 # default port 873
- Uid = 0 # No uid is specified. No account can be used without this line.
- Gid = 0 # do not specify gid
- Max connections = 10 # max connections 10
- # Module definitions
- # Remember cygwin naming conventions: c: work becomes/cygwin/c/work
- [Web_1]
- Path =/cygdrive/d/www/web_1 # path to be backed up (d Drive www/web_1 directory)
- Read only = false # read-only
- Transfer logging = yes # record transfer logs
- Ignore errors # ignore unrelated IO errors
- List = no # non-column file table
- Hosts allow = 10.8.5.0/255.255.255.0 # IP addresses allowed for access
- Hosts deny = * # Do Not allow access from any IP address other than hosts allow
- [Web_2]
- Path =/cygdrive/d/www/web_2 # path to be backed up (d Drive www/web_2 directory)
- Read only = false # read-only
- Transfer logging = yes # record transfer logs
- Ignore errors # ignore unrelated IO errors
- List = no # non-column file table
- Hosts allow = 10.8.5.0/255.255.255.0 # IP addresses allowed for access
- Hosts deny = * # Do Not allow access from any IP address other than hosts allow
3. After the configuration file is modified, manually start the RsyncServer service, netstat-an. Check if port 8173 is listening.
Iii. Target Server installation and configuration (rsync client)
1、double-click cwrsync_4.1.0_installer.exe, and then perform the next step
2. Compile batch files for timed updates
10.8.5.2 (rsync. bat)
- @ Echo off
- C: \ "Program Files" \ cwRsync \ bin \ rsync.exe-avzP -- progress -- delete rsync: // 10.8.5.240: 8173/web_1/cygdrive/d/www/web_1> d: \ rsync _ % date :~ 0, 10%. log
10.8.5.3 (rsync. bat)
- @ Echo off
- C: \ "Program Files" \ cwRsync \ bin \ rsync.exe-avzP -- progress -- delete rsync: // 10.8.5.240: 8173/web_2/cygdrive/d/www/web_2> d: \ rsync _ % date :~ 0, 10%. log
Or add C: \ "Program Files" \ cwRsync \ bin \ to the user's environment variable. In this example, no absolute path is required before rsync.exe.
3. parameter description
-A parameter, equivalent to-rlptgoD,
-R is recursion
-L indicates a link file, which means copying a link file;
-P indicates that the original file permission is maintained;
-T preserve the original time of the file;
-G: Retain the original user group of the file;
-O maintain the original owner of the file;
-D is equivalent to a block device file;
-Z compression during transmission;
-P transmission progress;
-V verbose, detailed mode output;
-U is used to synchronize only updated files, so as to avoid repeated updates to non-updated files. However, pay attention to the synchronization between the two machine clocks;
-- Progress displays the backup process;
-- Delete: delete the files that are not in the SRC file in DST and used for file synchronization;
4. Set scheduled tasks
Synchronize every 5 minutes
5. Manually test synchronization Information
- C: \ "Program Files" \ cwRsync \ bin \ rsync.exe-avzP -- progress -- delete rsync: // 10.8.5.240: 8173/web_1/cygdrive/d/www/web_1