Windows ubuntu 之前cwRsync 数据同步备份 工具环境配置及使用

来源:互联网 发布:让人喜欢的女生知乎 编辑:程序博客网 时间:2024/06/05 21:50

cwRsync_4.0.3_Installer.exe下载连接:

:http://download.csdn.net/detail/u013420428/9856353


1.Windos下安装cwRsync

cwRsync_4.0.3_Installer.exe


2.Windos下cwRsync环境变量设置
将以下目录添加到系统环境变量path
C:\Program Files (x86)\cwRsync  ;Win7
C:\Program Files\cwRsync ;XP

C:\Program Files (x86)\cwRsync\bin; Win7

C:\Program Files \cwRsync\bin; XP


3.Windos下添加home环境变量(用于生成ssh-keygen)
在C:\Program Files (x86)\cwRsync目录下新建home文件夹
在系统环境变量里新加
环境变量:HOME
路径:C:\Program Files (x86)\cwRsync\home


4.生成RSAkey
进入C:\Program Files (x86)\cwRsync\home
>ssh-keygen -t rsa
一路回车
在C:\Program Files (x86)\cwRsync\home目录下会生成.ssh目录里面id_rsa id_rsa.pub


5.添加rsa key到ubuntu服务器
进入C:\Program Files (x86)\cwRsync\home\.ssh目录
rsync -av id_rsa.pub 用户名@IP地址:~/.ssh/new_key.pub
按提示输入yes  再按提示输入服务器用户的密码
此步其实就是把id_rsa.pub 文件 拷贝到 服务器的~/.ssh/new_key.pub


6.在服务器端加入rsa.
$cd ~/.ssh/
进入服务器的.ssh目录
cat new_key.pub >> authorized_keys


如果authorized_keys文件权限不对:
最好设下权限
.ssh 目录权限为 700,
authorized_keys 权限为 600:
sudo chmod 600 authorized_key




7.Windows 同步命令行编写
拷贝一份C:\Program Files (x86)\cwRsync\cwrsync.cmd  为mysync.cmd
修改mysync.cmd
在文件结尾添加:
REM ** CUSTOMIZE ** Enter your rsync command(s) here
echo "start sync for mstar mboot ..."

rsync -azvrl --progress  --delete --exclude="*.o" /cygdrive/y/file/project  song@192.168.8.27:/mnt/databak/songyl.bak/


 /cygdrive/y windows的y盘 也可以改为c d e f盘

SET HOME=C:\Program Files (x86)\cwRsync\home  要与实际配置目录相同


运行mysync.cmd 会把windows下的指定文件夹同步备份到 ubuntu服务器指目录下


mysync.cmd

@ECHO OFF
REM *****************************************************************
REM
REM CWRSYNC.CMD - Batch file template to start your rsync command (s).
REM
REM By Tevfik K. (http://itefix.no)
REM *****************************************************************


REM Make environment variable changes local to this batch file
SETLOCAL


REM ** CUSTOMIZE ** Specify where to find rsync and related files (C:\CWRSYNC)
SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNC


REM Set CYGWIN variable to 'nontsec'. That makes sure that permissions
REM on your windows machine are not updated as a side effect of cygwin
REM operations.
SET CYGWIN=nontsec


REM Set HOME variable to your windows home directory. That makes sure 
REM that ssh command creates known_hosts in a directory you have access.
REM SET HOME=%HOMEDRIVE%%HOMEPATH%
SET HOME=C:\Program Files (x86)\cwRsync\home


REM Make cwRsync home as a part of system PATH to find required DLLs
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%


REM Windows paths may contain a colon (:) as a part of drive designation and 
REM backslashes (example c:\, g:\). However, in rsync syntax, a colon in a 
REM path means searching for a remote host. Solution: use absolute path 'a la unix', 
REM replace backslashes (\) with slashes (/) and put -/cygdrive/- in front of the 
REM drive letter:
REM 
REM Example : C:\WORK\* --> /cygdrive/c/work/*
REM 
REM Example 1 - rsync recursively to a unix server with an openssh server :
REM
REM       rsync -r /cygdrive/c/work/ remotehost:/home/user/work/
REM
REM Example 2 - Local rsync recursively 
REM
REM       rsync -r /cygdrive/c/work/ /cygdrive/d/work/doc/
REM
REM Example 3 - rsync to an rsync server recursively :
REM    (Double colons?? YES!!)
REM
REM       rsync -r /cygdrive/c/doc/ remotehost::module/doc
REM
REM Rsync is a very powerful tool. Please look at documentation for other options. 
REM


REM ** CUSTOMIZE ** Enter your rsync command(s) here
echo "start sync for mstar mboot ..."
rsync -azvrl --progress  --delete --exclude="*.o" /cygdrive/y/mstar/dvb_mboot song@192.168.8.27:/mnt/databak/songyl.bak/mstar/


echo "start sync for mstar app ..."
rsync -azvrl --progress  --delete --exclude="*.o" /cygdrive/y/mstar/dvb_app song@192.168.8.27:/mnt/databak/songyl.bak/mstar/


echo "start sync for sunplus ..."
rsync -azvr --progress  --delete --exclude="*.o" --exclude="*.d" /cygdrive/y/sunplus song@192.168.8.27:/mnt/databak/songyl.bak/


echo "start sync for gx ..."
rsync -azvr --progress  --delete --exclude="*.o" --exclude="*.d" /cygdrive/y/gx song@192.168.8.27:/mnt/databak/songyl.bak/


echo "start sync for mstar dvb_rom ..."
rsync -azvrl --progress  --delete --exclude="*.bak" /cygdrive/e/dvb_rom song@192.168.8.27:/mnt/databak/songyl.bak/


echo "start sync for doc ..."
rsync -azvrl --progress  --delete --exclude="*.bak" /cygdrive/e/dvb_doc song@192.168.8.27:/mnt/databak/songyl.bak/


echo "start sync for dvb_customer ..."
rsync -azvrl --progress  --delete --exclude="*.bak" /cygdrive/e/dvb_customer song@192.168.8.27:/mnt/databak/songyl.bak/


echo "Anything Rsync ok ^.^"
pause



1 0
原创粉丝点击