centos7下添加oracle定时备份(远程服务器)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a1010256340/article/details/88192973

  Linux下Oracle自动备份就没有MSSQL那么简单,在Linux下Oracle的备份需要借助crontab 指令,crontab 能够自动执行系统定时任务,通过配置crontab 指向Oracle定时备份指令完成数据的定时备份。

1、编写数据库备份脚本文件(oracle.sh)

#/bin/bash
source /etc/profile
exp satp/[email protected]/ORCL2 owner=satp  file=/data/20oracle_satp_bak/satp_$(date +%Y-%m-%d_%H:%M:%S).DMP
find /data/20oracle_satp_bak/ -mtime +2 -name "*.DMP" -exec rm -rf {} \;

备注:执行脚本的用户得拥有对应的文件目录权限

2、编辑脚本文件为可执行文件

chmod +x /data/oracle.sh

3、编写定时任务crontab脚本

[root@localhost data]# crontab -e
42 16 * * * /data/oracle_back.sh
#每天的16点42分自动执行脚本文件,执行完成之后,系统自动发送一封执行邮寄到root文件里面(/var/spool/mail/root)
#清空root文件内容的命令,如果需要清理文件内容 
​​​​​​​true  > /var/spool/mail/root

4、跟踪执行结果

tail -f /var/log/cron  #跟踪查询定时任务是否执行
cat /var/spool/cron/root #查询root下有那些定时任务

5、待续问题

 crontab执行完成可以发送Email,该功能的具体配置,还没研究....

猜你喜欢

转载自blog.csdn.net/a1010256340/article/details/88192973