rsync從windows到linux的同步備份

來源:互聯網
上載者:User

標籤:

名稱 角色 IP地址
Windows server 2003 伺服器 Eth0:192.168.1.1
RHEL5.5 用戶端 Eth0:192.168.1.2
 一、cwRsyncServer服務端配置下載服務端cwRsyncServer解壓cwRsyncServer_4.0.3_Installer.zip,雙擊cwRsyncServer_4.0.3_Installer.exe
 我的電腦—右鍵管理---服務和應用—服務找到RsyncSever,雙擊—啟動
 提供案頭互動
 
開啟E盤,建立要備份的檔案夾,此處取名為benet(此處是檔案夾,不是檔案)按右鍵benet檔案夾,選擇屬性,切換到安全選項,點添加輸入:SvcCWRSYNC
 
開啟C:\Program Files\ICW目錄用記事本開啟rsyncd.conf,修改添加以下內容(修改之前先備份,以防出錯重改)
 
編輯rsyncd.conf檔案use chroot = falsestrict modes = falsehosts allow = *log file = rsyncd.log # Module definitions# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work#
 [benet] #備份模版path = /cygdrive/e/benetread only = true #用戶端唯讀hosts allow = 192.168.1.2 #允許串連IP,多個IP中間用英文狀態下逗號隔,不限制IP填寫 *即可auth users = benet #允許串連的使用者名稱secrets file = etc/rsyncd.secrets #存放使用者名稱密碼的認證檔案路徑
 
在C:\Program Files\ICW目錄下面建立/etc/rsyncd.secrets檔案用記事本開啟,輸入使用者名稱和密碼benet:123 
二、Rsync用戶端配置1、查看selinux機制,關閉selinux[[email protected] ~]# getenforceDisabled2、開啟防護牆tcp 873連接埠,以便日後改為伺服器使用[[email protected] ~]# vi /etc/sysconfig/iptables #編輯防火牆設定檔-A INPUT -m state –state NEW -m tcp -p tcp –dport 873 -j ACCEPT
 3、安裝Rsync用戶端軟體[[email protected] ~]# yum install rsync xinetd[[email protected] ~]# vi /etc/xinetd.d/rsync #編輯設定檔,設定開機啟動rsync ,Centos上的rsync使用xinetd啟用的將disable=yes,改為noservice rsync{        disable = no        socket_type     = stream        wait            = no        user            = root        server          = /usr/bin/rsync        server_args     = --daemon        log_on_failure += USERID}/etc/init.d/xinetd start #啟動
 4、測試遠程一下測試一下是否可以正常通訊,安裝telnet[[email protected] ~]# telnet 192.168.1.1 873 #成功Trying 192.168.1.1...Connected to 192.168.1.1 (192.168.1.1).Escape character is ‘^]‘.@RSYNCD: 30.0
 同步資料為了輸入時不手動輸入密碼,我們在用戶端也建立一個和服務端一樣的密碼檔案(此檔案路徑和密碼要與伺服器端的一樣,用戶端不用寫名字)[[email protected] ~]# echo “123”> /etc/rsyncd.secrets #檔案名稱可以不一樣,但要在/etc下[[email protected] ~]# cat /etc/rsyncd.secrets123[[email protected] ~]# chmod 600 /etc/rsyncd.secrets
 在用戶端同步資料注意:此處的密碼為cwRsyncServer服務端C:\Program Files\ICW\etc\rsyncd.secrets檔案配置的密碼[[email protected] ~]# rsync -avz --password-file=/etc/rsyncd.secrets [email protected]::benet /opt/receiving file list ... done./11.txt sent 91 bytes received 192 bytes 51.45 bytes/sectotal size is 52 speedup is 0.18
 5.實現自動同步資料,手動編寫一個小指令碼。冒號後面的為在伺服器端定義的模版[[email protected] ~]# vim rsync.sh#!/bin/bash/usr/bin/rsync -avz --password-file=/etc/rsyncd.secrets [email protected]::benet /opt加入自動化備份[[email protected] ~]# chmod +x /root/rsync.sh[[email protected] ~]# crontab -e*       *       *       *       *       /root/rsync.sh

rsync從windows到linux的同步備份

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.