全备
原文:https://www.yuque.com/wei01/rlggh6/fpqft1
使用root执行 ,也可以用Oracle执行
crontab -l
00 23 * * * su - oracle -c "sh /home/oracle/scripts/rman_full.sh ">/home/oracle/rman_backup.log
########################################################################
# System Name : Backup db Shell
# Prog Name : rman_full.sh
# Description : Backup of database by rman
# Copyright all Reserved.
#######################################################################
echo "`date` backup start"
export ORACLE_SID=orcl1
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
DAY_TAG=`date +"%Y-%m-%d"`
$ORACLE_HOME/bin/rman target / nocatalog msglog /mnt/backup/orcl/rman/orcl_full_$DAY_TAG.log<<EOF
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup as compressed backupset database format '/mnt/backup/orcl/rman/Full_%d_%T_%s.bak';
sql 'alter system archive log current';
backup as compressed backupset filesperset 10 format '/mnt/backup/orcl/rman/Arch_%d_%T_%s.bak' archivelog all;
backup current controlfile format '/mnt/backup/orcl/rman/CTL_%d_%T_%s.bak';
backup spfile format '/mnt/backup/orcl/rman/SPFILE_%d_%T_%s.bak';
release channel d1;
release channel d2;
release channel d3;
release channel d4;
report obsolete;
delete noprompt obsolete;
}
EOF
echo "`date` backup successful"
exit
日志备份
crontab -l
0 */6 * * * su - oracle -c "sh /home/oracle/scripts/rman_arch.sh ">/home/oracle/rman_arch_backup.log
########################################################################
# System Name : Backup db Shell
# Prog Name : rman_arch.sh
# Description : Backup of database by rman
# Copyright all Reserved.
#######################################################################
echo "`date` backup start"
export ORACLE_SID=orcl1
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
DAY_TAG=`date +"%Y-%m-%d"`
$ORACLE_HOME/bin/rman target / nocatalog msglog /mnt/backup/orcl/rman/orcl_arch_$DAY_TAG.log<<EOF
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
crosscheck archivelog all;
delete noprompt expired archivelog all;
sql 'alter system archive log current';
backup as compressed backupset filesperset 10 format '/mnt/backup/orcl/rman/Arch_%d_%T_%s.bak' archivelog all;
backup current controlfile format '/mnt/backup/orcl/rman/CTL_%d_%T_%s.bak';
backup spfile format '/mnt/backup/orcl/rman/SPFILE_%d_%T_%s.bak';
release channel d1;
release channel d2;
release channel d3;
release channel d4;
report obsolete;
delete noprompt obsolete;
}
EOF
echo "`date` backup successful"
exit