Windows Server 2008 File synchronization

Source: Internet
Author: User
Tags rsync

Configure Windows Server 2008 file synchronization Summary: It is well known that Linux systems can use rsync to synchronize files or directories, as well as Windows systems. We now use Cwrsync to implement file synchronization under the Windows Server 2008 system. One, System environment operating system: Windows Server R2 update source server ...
As is known to all, Linux systems can use rsync to achieve file or directory synchronization, Windows system can be the same. We now use Cwrsync to implement file synchronization under the Windows Server 2008 system. I. SYSTEM environment Operating system: Windows Server R2 Update source server: 192.168.0.108 destination server: 192.168.0.132 Service side: cwrsyncserver_4.1.0_ Installer client: Cwrsync_4.1.0_installer Second, update the source Server installation configuration (Cwrsync service side) 1. Double-click Cwrsyncserver_4.1.0_installer.exe to open the installation interface, and then the next step, install Cwrsync server by default there is an administrator account Svccwrsyn, you can set your own user name and password.

2. Modify the Rsyncserver configuration file (C:\Program files (x86) \icw\rsyncd.conf)

  1. Use chroot = false #不使用chroot
  2. Strict modes = false #静态模式
  3. Hosts allow = * #配置全局哪些IP可以访问
  4. Log file = Rsyncd.log #log文件名, you can specify the path
  5. PID file = Rsyncd.pid
  6. Port = 8173 #默认端口873
  7. UID = 0 #不指定uid, no account will be used without this line
  8. GID = 0 #不指定gid
  9. Max connections = Ten #最大连接数10
  10. Lock file = Rsyncd.lock
  11. # Module Definitions
  12. # Remember Cygwin naming conventions:c:\ workbecomes/cygwin/c/ work
  13. #
  14. [Test]
  15. Path =/cygdrive/f/xuad #需要同步的路径 (F:\xuad directory)
  16. Read Only = false #只读权限
  17. Transfer logging = yes #记录传输日志
  18. Ignore Errors #忽略无关的IO错误
  19. List = No #不列文件表
  20. Hosts allow = 192.168.0.132/255.255.255.0 #允许访问的IP地址
  21. Hosts deny = * #不允许hosts Any IP access other than allow

3. After the installation is complete, you can see the cwrsync corresponding service in the "service", and you need to start the service manually after the installation is complete. Set the startup mode of the Rsyncserver to Automatic, and then start the service. Note: For directories that need to be synchronized, do not forget the permissions that are read to the Svccwrsync user.

4. Use NETSTAT–ANP TCP to see if Port 8173 is listening, and the client server Telnet 192.168.0.108 8173 to see if the port is up.

Third, the destination server installation configuration (Cwrsync client)

1. Double-click Cwrsync_4.1.0_installer.exe to open the installation screen, and then go the next step until the installation is complete.

2. Manual Test Synchronization

Enter RSYNC.EXE-AVZP--progress–delete rsync://192.168.0.108:8173/test/cygdrive/f/under Path C:\Program files\cwrsync\bin Xuad, appears as a message stating that synchronization was successful.

Parameter description

-a parameter, equivalent to-rlptgod,

-R is recursive

-L is a linked file, which means copying a linked file;

-p means to maintain the original permissions of the file;

-T keeps the file in its original time;

-G Keep the original user group of the file;

-O Keep the original owner of the document;

-d equivalent to block device files;

-Z compression during transmission;

-P transmission progress;

-v verbose, verbose mode output;

-U is to synchronize only the files that have been updated, to avoid the files that have not been updated repeatedly, but pay attention to the synchronization of the two machine clocks;

--progress display the backup process;

--delete Delete those files that are not in the DST SRC, used as synchronization files;

3. Scheduled Automatic Update configuration

(1) Write the Rsync.bat batch processing script

    1. @echo off
    2. Set rsynclog="C:\rsynclog\rsync.log"
    3. Set nowtime=%date:~0,10%%time%
    4. echo%nowtime% >>%rsynclog%
    5. cd/d c \"program Files" \cwrsync\bin
    6. Rsync.exe-avzpu --progress--delete rsync://192.168.0.108:8173/test/cygdrive/c/xuad >>%rsynclog%
    7. @echo -------------------------------------------------->>%rsynclog%
    8. @echo. >>%rsynclog%

(2) Set up Scheduled Tasks (synchronize every 5 minutes)

Start-Administrative Tools-Task Scheduler

Right-click Task Scheduler Local to open the Create task interface. Enter a name (task name), select the account that initiates the task, and select run regardless of whether the user is logged on or not.

Click "Trigger"-"new" to open the new trigger interface. Press set to synchronize every 5 minutes.

Click "Actions"-"new" to open the new operator interface. Press set, select the previously edited bat script, and then click OK.

Both conditions and settings use the default settings, then OK, enter the password for the user account that is running the task, click OK, and create the task plan to complete.

Iv. errors in the test

1. Command input Error

The red box should be labeled as the module name in the rsyncd.conf file instead of synchronizing the directory name. 2. Firewall blocked this port

You need to add a rule to allow this port in the firewall's inbound rules.

Important note for multiple servers to do file synchronization, it is best to do together with the data backup. For example: There are a, B, C, D four servers, you need to ensure that four servers one or more directory data consistency, that is, BCD needs to synchronize one or more directories from a data, then a is to update the source server, BCD is the destination server. Now there is a problem, when a data problems or lost, then BCD three of the data will be problematic and lost, in order to ensure that a's data must be correct, we have to update a server before the a data backup. The following is a simple bat script that enables automatic data backup and upload to an FTP server, which can be added to the Task Scheduler to execute it regularly. The contents of the Backup.bat script are as follows:
  1. @echo off
  2. Set today=%date:~0,10%
  3. Set nowh=%time:~0,2%
  4. Set nowtime=%date:~0,10%%time%
  5. Set rar="C:\Program files\winrar\rar.exe"
  6. Set ftplist="E:\baklog\ftpls.txt"
  7. Set baklog="E:\baklog\backup.log"
  8. Set ftpsrv=192.168.0.109
  9. Set ftpport=21
  10. Set Ftpuser=bak
  11. Set ftppwd=bak1q2w3e
  12. echo%nowtime% >>%baklog%
  13. :: Rar Files
  14. %rar% a E:\backup\backup_%today%_%nowh%.rar F:\xuad >>%baklog%
  15. :: Upload files by ftp
  16. echo open%ftpsrv%%ftpport% >%ftplist%
  17. echo user%ftpuser%%ftppwd% >>%ftplist%
  18. Echo CD Backup >>%ftplist%
  19. Echo Bin >>%ftplist%
  20. echo Prompt >>%ftplist%
  21. echo LCD E:\backup >>%ftplist%
  22. echo Put Backup_%today%_%nowh%.rar >>%ftplist%
  23. Echo Quit >>%ftplist%
  24. echo Bye >>%ftplist%
  25. Ftp-n-s:%ftplist% >>%baklog%
  26. Echo. >%rarlist%
  27. @echo -------------------------------------------------->>%baklog%
  28. @echo. >>%baklog%

Windows Server 2008 File synchronization

Related Article

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.