Windows Files sync to Linux__linux

Source: Internet
Author: User
Tags auth error code iptables rsync server port

Synchronizing Windows Server software to Linux server implementation

1, General Linux on the default installed with Rsync software

one. View and install

See if Rsync is installed

Command # Rpm–qa | grep rsync




<!--[endif]-->

If there is a corresponding rsync version, then the corresponding Linux already has rsync.

Otherwise, you will need to manually download the installation. Specific way to have

Software installation is too simple, now Linux major distributions are provided this software package, of course, you can also compile their own installation, in the current situation, I do not see much need;

[root@linuxsir:beinan]$ sudo apt-get install rsync Note: Online installation methods in Debian, Ubuntu, etc.;
[root@linuxsir:beinan]# slackpkg Install rsync Note: Slackware package online installation;
[root@linuxsir:beinan]# yum Install rsync Note: Fedora, Redhat, etc. system installation method;

Other Linux distributions, please use the appropriate package management methods to install, if it is the source package, that is, the following method;

[root@linuxsir:/home/beinan]# tar xvf sync-xxxx.tar.gz or sync-xxx.tar.bz2
[root@linuxsir:/home/beinan]# CD Sync-xxx
[root@linuxsir:/home/beinan/sync-xxx]#./configure--prefix=/usr; make install Note: Before compiling the installation with the source package, you have to install GCC and so on to compile the issuing line;

two modifying The configuration file for rsync



You can see that the RYSNC service is turned off (disable = yes), open it here and change the disable value to No

Third, rsync configuration of the server pieces rsyncd.conf ;

We can refer to rsyncd.conf.html. The concrete steps are as follows;

[root@linuxsir:~] #mkdir/ETC/RSYNCD Note: Create a RSYNCD directory under the/ETC directory that we use to store rsyncd.conf and rsyncd.secrets files;
[root@linuxsir:~] #touch/etc/rsyncd/rsyncd.conf Note: Create rsyncd.conf, which is the configuration file for the rsync server;
[root@linuxsir:~] #touch/etc/rsyncd/rsyncd.secrets Note: Create Rsyncd.secrets, this is the user password file;
[root@linuxsir:~] #chmod 600/etc/rsyncd/rsyncd.secrets Note: For the security of the password, we set the permission to 600;
[root@linuxsir:~] #ls-lh/etc/rsyncd/rsyncd.secrets
-RW-------1 root 2007-07-15 10:21/etc/rsyncd/rsyncd.secrets
[root@linuxsir:~] #touch/ETC/RSYNCD/RSYNCD.MOTD

The next step is when we modify rsyncd.conf and Rsyncd.secrets and RSYNCD.MOTD files.

Rsyncd.conf is the main configuration file for Rsync server, let's take a simple example, for example, we want to back up the server/home and/opt, in/home, I want to exclude Beinan and samba directory;

# Distributed under the terms of the GNU general public License v2

# Minimal configuration file for rsync daemon
# to Rsync (1) and rsyncd.conf (5) man pages for help

# This are required by THE/ETC/INIT.D/RSYNCD script

UID = root #这个用户是系统用户, when the Rsync client connects to the server, it maps to the user to upload or download

Use chroot = no

Max connections = 4 #最大允许并法链接数

Strict modes = yes

Port = 873 #rsync服务对应的端口

[Demo] # # module name, own name must be specified and unique

Path =/home/pigga/test #需同步的文件夹

Comment = this is test

Auth users = Scihoo #rsync的用户名是客户端使用的, the connection is successfully mapped to the UID user above

UID = root #这个用户是系统用户, when the Rsync client connects to the server, it maps to the user to upload or download

GID = root #组名效果同上

Secrets file =/etc/rsyncd/rsyncd.secrets #密码所在文件

Read Only = no #不是只读模式这样用户就有上传的权限了

List = yes #用户具有list目录的权限, the catalog is visible after the upload, and the listing shows

Hosts allow = * #允许所有网段的地址连接至服务器, you can specify the specific IP to/split

Note: about auth users is a real system user that must exist on the server, and if you want to use multiple users, separate the numbers, such as auth users = Beinan, Linuxsir

Password file:/etc/rsyncd/rsyncd.secrets content format;

User name: password Example:

Scihoo:scihoo

Note: The password here is worth noting, for security, you cannot write the password for the system user here. For example, your system user Linuxsir password is ABCDEFG, in order to be safe, you can let the Linuxsir in rsync be 222222. This is the same as the user-authenticated password principle of samba;

RSYNCD.MOTD documents;

It defines the RYSNC server information, which is the user login information. For example, let users know who the server is provided, and so on, similar to the FTP server login, we see the linuxsir.org ftp ... Of course, this is not necessary when defining variables globally, you can use the # number to note it, or delete it; I wrote a rsyncd.motd here that reads:

+++++++++++++++++++++++++++
+ linuxsir.org rsync 2002-2007 +
+++++++++++++++++++++++++++

Four. Start the rsync server and firewall settings;


4.1
start rsync server;

Starting the rsync server is fairly straightforward, –daemon is letting rsync run in server mode;

[Root@linuxsir:~]#/usr/bin/rsync--daemon--config=/etc/rsyncd/rsyncd.conf

Note: If you can't find rsync commands, you should know where rsync is installed. For example, rsync executable commands may be installed in the/usr/local/rsync/bin/rsync directory, which is the following command;

[Root@linuxsir:~]#/usr/local/rsync/bin/rsync--daemon--config=/etc/rsyncd/rsyncd.conf






4.2 rsync
servers and firewalls;

Linux Firewall is used iptables, so we at least on the server side to let you define the Rsync server port through, the client should also let pass.

[root@linuxsir:~] #iptables-A input-p tcp-m State--state new-m TCP--dport 873-j ACCEPT
[root@linuxsir:~] #iptables-L to see if the firewall is open 873 ports;

I'm here to add a port on the firewall through the graphical interface.

Check to see if the corresponding port is turned on or use Netstat–an and then use Telnet on another machine to determine if you can pass through the firewall.

Another: View the system process. Ps–ef, check to see if rsync is turned on

2, window client

Install the Cwrsyncserver client on the Windows machine and use cwrsyncserver_4.0.6_installer.zip locally. Can be downloaded on the Internet;

After installation, we write a batch process to achieve the download and upload function

Upload: Upload file to Linux for window-specific path
<!--[If!supportlinebreaknewline]-->
<!--[endif]-->

@ECHO off
D:
CD "Program Files\cwrsyncserver\bin"

Rsync-vzrtopg–progress--delete/cygdrive/d/websoft/scihoo@192.168.1.43::d emo--password-file=/cygdrive/d/ Rsyncd.secrets


Where/cygdrive/e/represents the Windows e disk

Note: This part of the d/websoft/Plus/for does not contain websoft upload, remove/upload with Websoft folder
D:/rsyncd.secrets password file, which contains only the password, does not contain the user


Download: Download to window client from Linux server specified path
<!--[If!supportlinebreaknewline]-->
<!--[endif]-->

@ECHO off
D:
CD "Program Files\cwrsyncserver\bin"

RSYNC-VRTOPG--progress--delete scihoo@192.168.1.43::d emo/cygdrive/d/websoft/

3, the password each time needs to manually enter the solution

This is an old problem, every time on the Windows host through the Cwrsync to the server to synchronize the data will encounter, this summary record. The error code is:

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.