Centos7.0 and windows2008 use Rsync for update (backup)

Source: Internet
Author: User
Tags auth windows download centos rsync


Rsync is a good free synchronization software for files. It can mirror and save the entire directory tree and file system, while maintaining the permissions, time, and soft links of the original file. During the first synchronization, rsync copies all the content and transfers only the modified part of the file next time. During data transmission, compression and decompression can be performed to reduce bandwidth traffic. Supports scp, ssh, and direct socket connections, and anonymous transmission. Supports Linux and Windows platforms. When writing this article, the latest version of window is 4.0.5.

Official website: http://rsync.samba.org/

Download Linux: http://rsync.samba.org/download.html

Windows Download: https://www.itefix.no/i2/cwrsync-get (Free Edition)

Client: cwRsync_4.0.5_Installer

Server: cwRsyncServer_4.0.5_Installer

Step 1: environment description

Windows Service 2008 as a server

Centos 7.0 as the client

Step 2: install Rsync server software

Run cwrsyncserver_4.0.5_installer.exe to install

The default installation path is C: \ Program Files \ ICW \

Do not modify the path. It is estimated that the installation fails because the path is modified. The installation is successful by default. There is one important step during the installation process.

You are required to enter the user name and password twice. Instead of creating a password, you must enter the rsync account and password used to log on to windows.

20141017221757

 

Enter the user name and password you want to set here. The user name and password will be used when two machines use rsync to communicate with each other.

If security software interception occurs during the creation process, you must allow the security software to perform this operation so that the creation can be successful.

Step 3: Configure Rsync

Configure the C:/Program Files/ICW/rsyncd. conf file. This is the installation directory, not necessarily here.

Use chroot = false

Strict modes = false

Hosts allow = *

Log file = rsyncd. log

Port = 873

Uid = 0 # uid and gid to be added; otherwise, @ ERROR: invalid uid nobody will be reported.

Gid = 0 # rsync error: error starting client-server protocol (code 5) at main. c (1506) [handler er = 3.0.2] error message

# Module definitions

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

#

[Backup] # This module name can be named at will

Path =/cygdrive/d/work # path of the file to be synchronized, representing the d: \ work Directory

Read only = false

Transfer logging = yes

List = no

Hosts allow = *

Auth users = rsync # rsync users can synchronize files under this configuration only for this account

Secrets file = etc/rsyncd. secrets # the account password that needs to be entered when rsync logs into the user file


Note:

The path is not a file path, but/cygdrive/(file path). Otherwise, an error is reported, indicating that the corresponding file or folder cannot be found.

Example: (the source code of the backed up website and the backed up website database are used as examples)


Use chroot = false
Strict modes = false
Hosts allow = *
Log file = rsyncd. log
Port = 873
Uid = 0
Gid = 0

# Module definitions
# Remember cygwin naming conventions: c: \ work becomes/cygwin/c/work
#
[515aaa]
Path =/cygdrive/d/websoft/www/xingyishu
Read only = false
Transfer logging = yes
List = no
Hosts allow = *
Auth users = 515aaa
Secrets file = etc/rsyncd. secrets

[515 aaaDataBase]
Path =/cygdrive/c/ProgramData/MySQL Server 5.1/data/xingyishu
Read only = false
Transfer logging = yes
List = no
Hosts allow = *
Auth users = 515aaa
Secrets file = etc/rsyncd. secrets

Note:

 

This user name and password are created at the beginning of installation.

 

Step 4: enable Rsync

 

Server Manager-tools-services for other versions of windows, you can use control panel-management tools-services

 

Find the rsyncserver service (if this service is not available, it should be your username and password, and you have entered a problem and uninstalled the re-installation once)

 

Set rsyncserver to automatically start and start the service

 

 

Note:

 

If any configuration file is modified during use, restart the service.

 

Step 5: configure the Rsync client (centos 7.0)

 

Normally, rsync is provided on linux machines. How can I check whether rsync software is installed in centos 7.0?

 



If you have installed wood, install it on your own.

 

First, add a password file to the client in the/etc/directory.


 

Ming:

 

Name and suffix customization, the content is the corresponding password

 

Set this file to 600 permissions.

 

1 Chmod 600 rsyncd_515aaa.scrt

 


After configuring the client, you can perform the rsync synchronization test.


Step 6:Allow the rsync client to automatically synchronize data with the server


The crontab command is used to execute tasks in a scheduled manner.

Crontab [-u username] [-l |-e |-r] options and parameters:-u: Only root can perform this task, that is, to help other users create/remove crontab work schedules;-e: edit crontab work content-l: View crontab work content-r: remove all crontab work content, to delete only one item, use-e to edit it.




Create two shell files for backup (515aaaCode. sh: Source code backup; 515aaaBaseData. sh: database backup)

Code: 515aaaCode. sh

#! /Bin/sh
# 515aaa Code BackCode-Jhonse
Rsync-vzrtopg -- progress -- delete -- password-file =/etc/rsyncd_515aaa.scrt 515aaa @ server address: 515aaa (module name) /data/code/$ (date + '% Y-% m-% d ')

Code: 515aaaBaseData. sh

#! /Bin/sh
# 515aaa DataBase Backup
Rsync-vzrtopg -- progress -- delete -- password-file =/etc/rsyncd_515aaa.scrt 515aaa @ server address: 515 aaaDataBase (module name) /data/database/$ (date + '% Y-% d-% M ')

Code: crontab command

20 22 ****./data/command/515aaaCode. sh
20 22 ****./data/command/515aaaDataBase. sh

 

You can use crontab-e to edit

 

Use crontab-l

 

 

Step 7: effect chart

 

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.