压在透明的玻璃上c-国产精品国产一级A片精品免费-国产精品视频网-成人黄网站18秘 免费看|www.tcsft.com

Rsync+SSH安全定時備份

  之前有寫個linux之間的Rsync備份,現在寫一份Rsync+ssh通道安全備份

  Server:   192.168.101.115

  Client:   192.168.101.116

  首先在 Client 做密鑰

  [root@Client .ssh]# ssh-keygen -t rsa -P ''

  Generating public/private rsa key pair.

  Enter file in which to save the key (/root/.ssh/id_rsa):

  Your identification has been saved in /root/.ssh/id_rsa.

  Your public key has been saved in /root/.ssh/id_rsa.pub.

  The key fingerprint is:

  8d:89:b6:f2:6c:34:9c:da:7e:a7:b1:02:59:a4:8e:f6 root@Client

  The key's randomart image is:

  上傳密鑰到 Server

  [root@Client /]# ssh-copy-id -i /root/.ssh/id_rsa.pub "-p 22 root@192.168.101.115"

  Server和 Client 都安裝 Rsync

  wget http://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gz

  tar zxvf rsync-3.0.9.tar.gz

  cd rsync-3.0.9

  ./configure –prefix=/usr && make && make install

  Server 配置Rsync

  [root@Server /]# vim /etc/rsyncd.conf

  uid = root

  gid = root

  use chroot = yes

  max connections = 3

  pid file = /var/run/rsyncd.pid

  lock file = /var/run/rsync.lock

  log file = /var/log/rsyncd.log

  port = 873

  hosts allow = 192.168.101.116

  log format = %t %a %m %f %b

  [web]

  comment = web file

  path = /data/bak

  ignore errors

  read only = no

  #write only = no

  list = no

  auth users = amei

  secrets file = /data/pad

  制作認證密碼文件  和 加入開機啟動

  [root@Server /]# echo 80uncle:80uncle > /etc/rsyncd.secrets

  [root@Server /]# chown root:root /etc/rsyncd.secrets //修改權限

  [root@Server /]# chmod 600 /etc/rsyncd.secrets

  Server 加入開機啟動:

  [root@Server /]# chkconfig rsync on

  或者

  [root@Server /]# chkconfig –add rsync

  Server 啟動 Rsync

  [root@Server /]# /usr/bin/rsync –daemon

  Client 加入開機啟動:

  [root@Client /]# chkconfig rsync on

  或者

  [root@Client /]# chkconfig –add rsync

  Client 啟動 Rsync

  [root@Client /]# /usr/bin/rsync –daemon

  最后在Client 編寫 shell

  [root@Client /]# vim /data/shell/ssh_rsync.sh

  #!/bin/bash

  /usr/bin/rsync -avz –delete -e ssh root@192.168.101.115:/data/bak /data/abc

  ######### -e ssh 是采用ssh模式 #########

  ### root@192.168.101.115:/data/bak 是Server要同步的文件夾

  ### /data/abc 是將Server 同步到本地的文件夾

  加入crontab定時執行

  00 01 * * * /data/shell/ssh_rsync.sh

  ###每天凌晨1點定時備份###

 

上一篇:安卓防火墻 PS DroidWall

下一篇:數據執行保護-run a dll as an app