MicroLPS


A personal website

Search

Site friends

Investworkflow.com 茶马股道 
PMP exam guilde referece 
PMI  IBM SAP

Catalog categories

UML [1]
Web technology and tools [13]
Javascript HTML XML CSS etc.
Lotus Domino [0]

Login form

Statistics


Total online: 1
Guests: 1
Users: 0

Our poll

Rate my site
Total of answers: 6
Tuesday, 2024-04-23, 8:03 PM
Welcome Guest
Main | Registration | Login | RSS

Publisher

Main » Articles » Software/Web Design and Development » Web technology and tools

使用rsync实现windows和linux两系统的文件同步



自从dropbox被墙了之后就一直在寻找更好的同步工具,毕竟使用同步工具比什么google doc和网易网盘要爽的多,起码不用上传下载,用了什么PathSync和DBSync都觉得不如dropbox的爽(纯属个人感觉哈).
其实我的需求倒是挺简单的,就是要同步家里和公司两台电脑的一些指定的文件夹,突然想到每天都在使用的rsync,自己配一个吧,反正服务器是现有的,只 不过是linux,两台需要同步的电脑都是windows,下面就分享一个rsync如何在windows和linux两个系统中进行文件同步.

linux服务端
按照rsync工具
建议采用yum install rsync 或 apt-get install rsync安装,因为方便嘛
安装完毕后

vi /etc/rsyncd.conf

pid file = /var/run/rsyncd.pid
uid 
= nobody
gid 
= nobody
max connections 
= 36000
log file 
= /var/log/rsync.log
transfer logging 
= yes
log format 
= %t %a %m %f %b
syslog facility 
= local3
syslog facility 
= local5

[test]
path 
= /home/html
comment 
= test
list 
= no
read only 
= false
use chroot 
= no
hosts allow 
= *
hosts deny 
= *
#auth users 
= root
#secrets file 
= /etc/rsync_root.pas

上面是全局设置,下面是建立了一个[test]模块,模块下面包含了个性配置,path指定模块的路径,hosts allow可以指定授权访问的ip,其中auth users参数可以设置访问的用户列表,如果不指定,则表示无需密码也可以访问同步,secrets file来用指定密码文件

vi /etc/rsync_root.pas

root:123

当配置完毕后我们启动rsync

rsync --daemon --config /etc/rsyncd.conf

window客户端

首先安装cwRsync工具,cwRsync_2.0.10_Installer.zip

安装完毕后,我们写个批处理来实现下载和上传的功能

上传:

@ECHO OFF
d:
cd 
"Program Files\cwRsyncServer\bin"
rsync -vzrtopg --progress --delete /cygdrive/e/synchro root@
184.82.19.165::test

其中/cygdrive/e/表示的是windows的E盘

下载:

@ECHO OFF
d:
cd 
"Program Files\cwRsyncServer\bin"
rsync -vzrtopg --progress --delete root@
184.82.19.165::test /cygdrive/e/synchro

好了,写好两个批处理后,把这两个批处理文件放到桌面上去,这样就可以随时随地的同步公司和家里两台电脑的文件,虽然很山寨吧,但用了几天感觉还是挺良好的

----------------------------------------

by 陈于喆
Mail: chenyz@corp.netease.com

Source:
Category: Web technology and tools | Added by: microlps (2012-10-19)
Views: 1333 | Rating: 0.0/0 |
Total comments: 0

Only registered users can add comments.
[ Registration | Login ]