当前位置

首页 > 计算机网络 > 软件技术 > windows和linux的文件同步工具rsync 与cwrsync使用教程

windows和linux的文件同步工具rsync 与cwrsync使用教程

推荐人: 来源: 昵称屋 阅读: 1.09W 次

rsync是Linux系统中最好用的文件同步备份工具之一,而且可以实现windows和linux的文件同步,如果你的项目中需要进行Windows 贺 Linux的数据同步,那么可以使用rsync +cwrsync实现文件同步。

windows和linux的文件同步工具rsync 与cwrsync使用教程:

在配置和实际的使用过程中遇到了很多问题,写成了一个教程,一方面巩固一下安装的过程,一方面希望能够帮助到在安装过程中遇到同样过程的人。

Rsync 客户端(cwRsync) 5.4.1 官方最新版:

cwRsync(Rsync for Windows)服务端&客户端:

安装环境:CentOS 7

一.服务器端配置

1.安装rsync    

yum install rsync

2.配置rsync     

vim /etc/ (如果没有此文件,请手动创建。使用 touch 或者 vim 直接编辑也是可以创建的)

###################################################

#下面是我的配置文件

uid = root #模块传输文件时守护进程应该具有的uid

gid = root #模块传输文件时守护进程应该具有的gid

#如果"use chroot"指定为true,那么rsync在传输文件以前首先chroot到path参数所指定的目录下。这样做的原因是实现额外的安全防护,但是缺点是需要以roots权限,并且不能备份指向外部的符号连接所指向的目录文件。默认情况下chroot值为true

use chroot = no

max connections = 4 #最大连接数

pid file = /var/run/

lock file =/var/run/

log file =/var/log/

#允许连接的ip,在演示中使用的云服务器就直接写*,表示无限制 如果要规定ip或者ip段需要进行其他配置

例如: 

hosts allow = *

timeout = 900 #超时设置

port = 873 #默认端口为873

#以下为设置同步的目录

[test]

path = /home/test #同步文件夹

#指定在 rsync 服务器上运行 delete 操作时是否忽略 I/O 错误。一般来说 rsync 在出现 I/O 错误时将将跳过 –delete 操作,以防止因为暂时的资源不足或其它 I/O 错误导致的严重问题。

ignore errors

read only = yes

list = yes 

hosts allow = * #指定连接的ip

auth users = test #指定同步的用户

#指定上述账号的密码文件,文件和拓展名可以自定义

secrets file = /etc/ 

###################################################

3.新建文件

该文件主要是指定连接用户的用户名和密码

格式为 name:password

需要注意的是需要修改此文件的权限否则连接时会出错

chmod 600 /etc/

4.设置连接提示信息

vim  /var/

5.防火墙设置

因为是centos7所以采用的是firewall

firewall-cmd --zone=public --add-port=873/tcp --permanent

命令含义:

--zone #作用域

--add-port=873/tcp  #添加端口,格式为:端口/通讯协议

--permanent   #永久生效,没有此参数重启后失效

重启防火墙

firewall-cmd --reload

6.启动rsync

rsync --daemon --config=/etc/

--daemon表示后台启动 --config 表示使用对应的配置文件

7.需要注意的是 

同步文件夹需要提前创建,并且修改其权限

chmod 655 test

windows和linux的文件同步工具rsync 与cwrsync使用教程

windows和linux的文件同步工具rsync 与cwrsync使用教程 第2张

二.客户端连接

windows机器上安装cwrsync

到安装目录下执行:

-vzrtopgu --progress --update test@ip::test /cygdrive/D/h

参数配置可参考官方文档或者以下博客:

test@ip::test  前面那个test为连接用户 ip 为服务器ip 后面那个test表示指定的模块

/cygdrive/D/h 表示本地的同步文件夹/D/h 为同步文件夹

windows和linux的文件同步工具rsync 与cwrsync使用教程 第3张

此时windows电脑文件夹内容已经和服务器同步了

windows和linux的文件同步工具rsync 与cwrsync使用教程 第4张

如果在连接过程中遇到了问题可以参考:

_

三.写在后面

在安装过程中困扰我最大的问题就是在服务器配置好以后一直连接不起。这次的演示环境是centos7,在自己摸索安装时使用的系统是centos6.5.还是有一些不同。在centos6.5中我使用的是xinetd+rsync。但是我使用xinetd启动时,使用的是  /etc/init.d/xinetd start 

但是一直会出现:

cwrsync rsync error rsync error: some files/attrs were not transferred 

错误,在参考了

还是没办法解决。最后使用 rsync --daemon --config=/etc/ 启动时问题莫名其名就得到了解决,自己也没有想通是为什么。所以在rsync上还需要多探索和研究。

热点阅读

  • 1I do not want to distinguish between the East and the west, I will only go to your direction.
  • 2win7 下面如何用电脑和 Windows Mobile 设备同步
  • 3How I want to say it, but can not express.
  • 4超拽有哲理的英文签名 Lose you win the world and how
  • 5What a pity it would be if you said that you can get red eyes when you dream
  • 6唯美风格图片 Some things, I can figure it out, can accept, but I still very sad.
  • 7不是所有的喜欢都能如愿以偿bu shi suo you de xi huan dou neng ru yuan yi chang
  • 8每个人都很特别你也不例外.Everyone is special,and you are no exception.
  • 9Close your worries, hang up the moon, and sleep well!
  • 10Good luck is when an opportunity comes along and you're prepared for it.
  • 11Be nice to yourself, That's the person who will be with you the longest. ​​​​
  • 12Spring breeze and I are both passers-by, and you bring your autumn waters to embrace the Milky Way.
  • 132014最新伤感英文签名带翻译 Crowded I always not see you
  • 14Ha-ha, that's ridiculous. Why should I pay for your suffering.
  • 15Thewindblowsawaythethoughts,rolledupunrulytime.(被风吹散的思念,卷起不羁的时间)
  • 16Said not to disturb, but still can't help but wonder if you're doing well.(纯蓝色女头)
  • 17I've never envied anyone else when you were with me.
  • 18Why don't you come to confess? I've already decided how to promise you.
  • 19In spite of you and me and the whole silly world going to pieces around us, I love you.
  • 20Buddha can not cross the world, I have to cross 佛渡不了的天下,有我来渡
  • 推荐阅读

  • 1微信开通检测工具使用教程 微信开通检测工具使用教程
  • 2二维码表白图♡ I desire to grow old with you without paying.
  • 3冉/Tears asked Huahua not language, chaos red fly over the swing. 手写(陈情令,肖战)
  • 4On a sunny afternoon, I was listening to a song with my headphones on.
  • 5双显卡驱动安装教程 提示you must install an intel driver first解决方法
  • 6软件搬家工具的使用教程
  • 7QQ空间 Surface dynasty sea bloomy spring
  • 8晗晗_ 绝美背景图“Cause I don”t know who you are
  • 9Windows10怎么升级Windows11 Windows10升级Windows11详细图文教程
  • 10在windows中用户建立的文件默认具有的属性是
  • 11微软测双胞胎工具twinsornot怎么玩?twinsornot官方介绍
  • 12ins真人男头 dt晕陷 养 林宇婧 74DranVlin 岛彻 灰塵緣 lsunicorn 浪漫与涵
  • 13情头 You're my within sight but beyond reach.
  • 14linux与windows的区别
  • 15德金(Draco Malfoy×Ginny Weasley)
  • 16个性经典的中英文签名 Your own taste, let my heart closely rely on
  • 17I may be born weak and have nothing special to like except you.
  • 18每日更新✨I haven't thought about sweet sentences yet. You can hug me first
  • 19Likes and injuries are directly proportional. (喜欢和受伤是成正比的.)
  • 20Fortunately, it was still young when I met you.幸好遇见你时还年少。
  • 212016chinajoy showgirl图片高清 美女showgirl手机壁纸
  • 22windows live skydrive功能简介 您的网络存储专家 如何添加文件
  • 23win7无法访问windows installer服务是什么情况 win7系统无法访问windows installer服务解决办法
  • 24Linux和Windows的区别 Linux和Windows的区别是什么
  • 25美丽个性非主流签名 Cry, already know what is love