rsync從linux到linux的檔案同步備份

來源:互聯網
上載者:User

COPY FROM : 

http://net.it168.com/a2009/0402/270/000000270638_1.shtml

 

一、環境

  需要備份檔案的伺服器(伺服器端):192.168.1.201 (RHEL 5)
  接收備份檔案的伺服器(用戶端):192.168.1.202 (CENTOS 5)
  
  二、安裝配置
   1.伺服器端的配置
      A、採用系統預設安裝的rsync 編輯/etc/rsyncd.conf檔案,如果沒有則建立一個。
     vi /etc/rsyncd.conf
  #[globale]
  strict modes= yes  #check passwd file
  port= 873 #default port
  logfile= /var/log/rsyncd.log
  pidfile= /var/run/rsyncd.pid
  max connections= 4
  #[modules]
  [testlink]   #備份模組
  uid= root
  gid= root
  path= /usr/local/apache/htdocs/testlink/upload_area  #要備份的目錄
  read only= no
  host allow= *
  auth users= wwyhy
  secrets file= /etc/rsyncd.scrt
  [bugfree]         #備份模組
  uid= root
  gid= root
  path= /usr/local/apache/htdocs/bugfree/BugFile         #要備份的目錄
  read only= no
  host allow= *
  auth users= wwyhy
  secrets file= /etc/rsyncd.scrt
  [redmine]   #備份模組
  uid= root
  gid= root
  path= /usr/local/redmine-0.8.1/files       #要備份的目錄
  read only= no
  host allow= *
  auth users= wwyhy
  secrets file= /etc/rsyncd.scrt
  
  B、 添加一個密碼檔案
  vi /etc/rsyncd.scrt
  內容如下:
  wwyhy:123456  #(自己設定)
  
  C、改變許可權為600
  chmod 600 /etc/rsyncd.scrt
  
  D、啟動服務(如開有防火牆請允許873連接埠通過)
  rsync --daemon --config=/etc/rsyncd.conf &
  
  2.配置用戶端
  用戶端我則自己編譯安裝的rsync-3.0.3.tar.gz的
  A、安裝:
  tar -zxvf rsync-3.0.3.tar.gz
  cd rsync-3.0.3
  ./configure
  make
  make install
  B、添加密碼檔案
  vi /etc/rsyncd.scrt (沒有就建立)
  內容如下:
  wwyhy:123456 (檔案與用戶端檔案內容一樣)
  C、改檔案許可權為600

  chmod 600 /etc/rsyncd.scrt

     三、開始備份
  可以在用戶端通過man rsync指令來查看備份指令
  我們用指令碼來自動執行備份
  列:rsync -avz --password-file=密碼檔案路徑 username@需要備份的主機IP::備份裡的模組名稱
   接收備份檔案的路徑
  在/root建一個指令檔
  vi backup
  
  新增內容如下:
  #1.192.168.1.201上的testlink附件備份指令
  rsync -avz --password-file=/etc/rsyncd.scrt wwyhy@192.168.1.201::testlink
  /home/wangwei/testlink/upload_area
  #2.192.168.1.201上的bugfree附件備份指令
  rsync -avz --password-file=/etc/rsyncd.scrt wwyhy@192.168.1.201::bugfree
  /home/wangwei/bugfree/BugFile
  #3.192.168.1.201上的redmine附件備份指令
  rsync -avz --password-file=/etc/rsyncd.scrt wwyhy@192.168.1.201::redmine
  /home/wangwei/redmine-0.8.1/files
  
  chmod u+x backup
  
  每晚2.30自動執行
  vi /etc/crontab
  
  30 2 * * * root /root/backup

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.