ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 怎样利用linux rsync 同步不同Server上的两个目录下的文件

怎样利用linux rsync 同步不同Server上的两个目录下的文件

原创 Linux操作系统 作者:tolywang 时间:2010-03-04 09:52:27 0 删除 编辑

we will configure script. to rsync archive log file from production db to standby db 


1. How to Rsync over SSH without a password.

 

a. Log into the TARGET host (standby db), and generate an RSA (public and private) key pair:

target$ ssh-keygen  -t   rsa

* Accept the default location for the key files (press [ENTER]).
* Enter and confirm a pass phrase. (empty for no passphrase) (it is not a requirement)


b. Log into the SOURCE host (production db), and confirm the existence of this file
   "/home/oracle/.ssh./authorized_keys" ,   create this file

source$ touch  ~/.ssh/authorized_keys

 

c.  Log into the SOURCE host, and get public key from TARGET:

source$ ssh target  cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

 

d.  Log into the TARGET host (here is Standby), and try to rsync:

target$ rsync -e ssh -av oracle@source:/ocfs_data/mxdell/arch/  /ocfs_data/mxdell/arch/  

 

 

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

 

 

改良的脚本,可以判断, 一个linux crontab job在运行,同样的一个如果再次运行会被终止。


#!/bin/bash


pid=`/sbin/pidof rsync`
if [ "$pid" ]
then
    echo "Rsync is already running...."
else
    echo "Starting rsync `date`"
    rsync -e ssh -av oracle@10.13.66.186:/ocfs_data/mxdell/arch/ /ocfs_data/mxdell/arch/
    echo "Completed rsync `date`"
fi
exit 0

 

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

 

#!/bin/bash


pid=`/sbin/pidof rsync`
if [ "$pid" ]
then
    echo "Rsync is already running...."
else
    echo "Starting rsync `date`"
    rsync -e ssh -av oracle@10.13.67.174:/ocfs_data/mxdell/arch/ /ocfs_data/mxdell/arch/
    echo "Completed rsync `date`"
fi

 

 

 

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/35489/viewspace-628557/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    14696720