linuxshell实现自动清理rman备份文件的脚本
来源:行业资讯 /
时间: 2024-12-13
rman备份脚本
#! /bin/bash<br/>
su - oracle <<!<br/>
rman target /<<EOF<br/>
backup AS COMPRESSED BACKUPSET database<br/>
include current controlfile format'/orabak_%d_%T_%s'<br/>
plus archivelog format'/orabak/arch_%d_%T_%s' delete allinput;<br/>
delete noprompt obsolete;<br/>
exit;<br/>
EOF<br/>
第三个备份保存平台自动清理过期的备份文件<br/>
#! /bin/bash<br/>
for file in `ls /orabak`<br/>
do<br/>
if [[ ${file:0:2} == "db" ]];then<br/>
fdate=${file:10:8}<br/>
mydate=`date +%Y%m%d -d "-7 day"`<br/>
if [[ $fdate < $mydate ]];then<br/>
rm -rf $file;<br/>
else<br/>
echo $file;<br/>
fi<br/>
else<br/>
fdate=${file:12:8}<br/>
mydate=`date +%Y%m%d -d "-7 day"`<br/>
if [[ $fdate < $mydate ]];then<br/>
rm -rf $file;<br/>
else<br/>
echo $file;<br/>
fi<br/>
fi
下一篇: LINUXSHELL抓取错误日志脚本