oracle rman备份脚本

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

全备:

cat arch_rman_backup.sh:


source /home/oracle/.bash_profile
rman target / log=/u01/app/script/arch_rman.log<<EOF
run
{
allocate channel ch1 device type disk;
allocate channel ch2 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 ch1;
release channel ch2;
}
EOF


归档日志备份:

$cat arch_rman_backup.sh


source /home/oracle/.bash_profile
rman target / log=/u01/app/script/arch_rman.log<<EOF
run
{
allocate channel ch1 device type disk;
allocate channel ch2 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 ch1;
release channel ch2;
}
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

猜你喜欢

转载自blog.51cto.com/1937519/2287049