Oracle expdp备份计划任务设计
程序员文章站
2024-03-13 16:34:39
...
一、使用expdp备份,首先要做的准备:
1.登录Oracle之后建立备份文件夹并赋权限:
create or replace directory dmp as '/home/OracleBackup/expdpbak';
grant read,write on directory dmp to SYSTEM;
2.测试备份脚本oracle_backup_expdp.sh
放到/home/oracle/scripts
文件夹下,并赋权
# chmod +x oracle_backup_expdp.sh
#!/bin/sh
#create or replace directory dmp as '/home/OracleBackup/expdpbak';
#grant read,write on directory dmp to system;
#echo "Test /oradata is mounted ..."
export DateStr=`date "+%Y%m%d"`
export DateStr2=`date "+%Y%m%d_%H%M%S"`
su - oracle <<EON
if test -d /home/OracleBakup/expdpbak
then
:
else
mkdir -p /home/OracleBackup/expdpbak
fi
expdp \'/ as sysdba\' directory=dmp dumpfile=expdp_$DateStr2.dmp logfile=expdp_$DateStr2.log schemas=easytong
exit
EON
if test -d /home/oracle/expdpbak
then
:
else
mkdir -p /home/oracle/expdpbak
fi
#cp /home/OracleBackup/expdpbak/expdp_$DateStr2.* /home/oracle/expdpbak
export DateStr=`date -d "7 days ago" "+%Y%m%d"`
cd /home/OracleBackup/expdpbak/
tar zcf expdp_$DateStr2.tar.gz expdp_$DateStr2.dmp expdp_$DateStr2.log
ftp -n -v 172.26.129.19 <<EOF **//此处是FTP服务器的地址,异地备份存放位置**
user expdp expdp
bin
put expdp_$DateStr2.tar.gz
prompt
mdelete expdp_$DateStr*.tar.gz
bye
EOF
mv expdp_$DateStr2.tar.gz /home/oracle/expdpbak/
str=expdp_$DateStr
find /home/OracleBackup/expdpbak/ -name "$str*" -exec rm {} \;
find /home/oracle/expdpbak/ -name "$str*" -exec rm {} \;
unset DateStr
unset DateStr2
3.时间服务器客户端配置
# yum install -y ntpdate //安装ntp服务
[[email protected] zytk]# ntpdate 120.25.108.11 //测试ntpdate可用,此处是阿里云提供的服务IP
11 Mar 17:59:16 ntpdate[4607]: adjust time server 120.25.108.11 offset -0.039831 sec
4.创建计划任务
# crontab -l //查看计划任务
# crontab -e //编辑计划任务
00 22 * * * /home/oracle/scripts/oracle_backup_expdp.sh #22点备份
10 * * * * /usr/sbin/ntpdate 120.25.108.11 #每小时的10分去同步时间
推荐阅读
-
Oracle expdp备份计划任务设计
-
Oracle备份还原(expdp/impdp)
-
Oracle中利用expdp/impdp备份数据库的使用说明
-
oracle如何用expdp定时备份?oracle用expdp实现定时备份数据库图文详细教程
-
通过数据泵expdp、impdp方式备份与还原/恢复 Oracle数据库(详细过程)
-
Oracle数据库的数据备份,本地,异地,exp-imp,expdp-impdp等实例讲解
-
oracle使用expdp定时备份数据库
-
Oracle expdp/impdp导出导入命令及数据库备份(转)
-
Oracle expdp/impdp导出导入命令及数据库备份(转)
-
oracle如何用expdp定时备份?oracle用expdp实现定时备份数据库图文详细教程