网站建设资讯

NEWS

网站建设资讯

oraclerman备份脚本

日常习惯使用netbackup进行数据库备份,但是经常环境中无netbackup,因此的自己写个脚本,脚本很简单,主要是写费时间,因此贴出来以备后用:

创新互联建站主营迭部网站建设的网络公司,主营网站建设方案,成都app软件开发公司,迭部h5小程序开发搭建,迭部网站营销推广欢迎迭部等地区企业咨询

全备:

cat arch_rman_backup.sh:


source /home/oracle/.bash_profile
rman target / log=/u01/app/script/arch_rman.log<run
{
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
sql 'alter system archive log current';
#backup database format '/backup/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/backup/arch_%U_%d_%T_%t' delete all input;
backup current controlfile format '/backup/ctl_%U_%d_%T_%t';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
#delete noprompt backup of database completed before 'sysdate -7';
#delete noprompt archivelog all;
#delete noprompt backup of archivelog all completed before 'sysdate -7';
release channel ch2;
release channel ch3;
}
EOF

归档日志备份:

$cat arch_rman_backup.sh


source /home/oracle/.bash_profile
rman target / log=/u01/app/script/arch_rman.log<run
{
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
sql 'alter system archive log current';
#backup database format '/backup/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/backup/arch_%U_%d_%T_%t' delete all input;
backup current controlfile format '/backup/ctl_%U_%d_%T_%t';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
#delete noprompt backup of database completed before 'sysdate -7';
#delete noprompt archivelog all;
#delete noprompt backup of archivelog all completed before 'sysdate -7';
release channel ch2;
release channel ch3;
}
EOF

添加执行权限:

chmod +x /u01/app/script/arch_rman_backup.sh

chmod +x /u01/app/script/full_rman_backup.sh

设置备份保留策略:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

添加定时任务:

0 */2 * * *   /u01/app/script/arch_rman_backup.sh
30 1 * * 0   /u01/app/script/full_rman_backup.sh


当前名称:oraclerman备份脚本
网站路径:http://cdweb.net/article/jpphsi.html