linux自动拷贝文件,并恢复ORACLE数据库

来源:互联网 发布:linux安装rpm文件 编辑:程序博客网 时间:2024/06/07 01:05
为了在脚本里使用scp命令不输入密码,需要在各主机间建立安全信息关系1创建证书[oracle@eastestdb2 ~]$ ssh-keygen -b 1024 -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/oracle/.ssh/id_rsa): Created directory '/home/oracle/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/oracle/.ssh/id_rsa.Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.The key fingerprint is:46:fa:16:6e:6f:1b:9a:eb:e9:c0:25:e5:dc:52:83:47 oracle@eastestdb2The key's randomart image is:+--[ RSA 1024]----+|          E      ||         o       ||        + +      ||       * + .     ||      o S .      ||     . * o       ||      o = .      ||       + =..     ||       oBoo.     |+-----------------+


2、将公钥证书复制到Server 的.ssh目录中
[oracle@eastestdb2 .ssh]$ scp -p id_rsa.pub oracle@192.168.100.36:/home/oracle/.ssh/authorized_keys

 

3、修改原有计划任务脚本,直接复制文件到备份服务器
[oracle@NEWEASDB ~]$ cat eascron_expdp_EAS_DAY.sh
expdp system/kingdee schemas=ORUSER directory=orabak dumpfile=zy_$(date "+%Y%m%d%H%M").dmp logfile=zy_$(date "+%Y%m%d%H%M").log
find /orabak -mtime +5 -name '*.dmp' | xargs rm
find /orabak -mtime +5 -name '*.log' | xargs rm
scp /orabak/zy_$(date "+%Y%m%d")0400.dmp oracle@192.168.100.36:/orabak


#[oracle@NEWEASDB orabak]$ scp /orabak/zy_$(date "+%Y%m%d")0400.dmp oracle@192.168.100.36:/orabak

 

4、在备份服务器上创建计划任务

crontab -e 创建任务
0 6 * * *       source /home/oracle/.bash_profile; /bin/sh /home/oracle/eascron_impdp_EAS_DAY.sh

 

5、创建计划任务执行的脚本文件,导入数据到备份服务器

vi /home/oracle/eascron_impdp_EAS_DAY.sh
impdp system/redhat schemas=ORUSER dumpfile=zy_$(date "+%Y%m%d")0400.dmp logfile=zy_$(date "+%Y%m%d")0400.log directory=orabak table_exists_action=replace
find /orabak -mtime +0 -name '*.*' | xargs rm -rf

0 0
原创粉丝点击