RMAN 脚本类型:
Select table_name from dictwhere TABLE_NAME like "%SGA%"
Select * from V$SGAINFO
1:RMAN脚本
@bak_user-schem.rman orrman @bak_user-schem.rmanorrman cmdfile=bak_user-schem.rman
connect target /
run{
allocate chanel CH1 type disk format '/home/oracle/%N_%s_%P_%t.bak';
backup tablespace users; orbackup tablespace users &2;
release channel CH1;
}
2:SHELL脚本 封装 Rman脚本
./bak_user-schem.sh user
umask 0022
rman <<EOF
@bak_user-schem.rman $1
EOF
3:Store Backup Script in the database
To create recoverary catalog database and then <connect catalog rman/oracledba@rmancat>
To create below script on the catalog database
create script bak_tablespace
{
allcocate ***
backup database ***
}
PS: to create a catalog databaseinstead of using control file to keep the related RMAN backup information, an independent box with Oracle installed should be in place and the RMAN recoverage database should be created there.
4: Examples for production RMAN backup script
Requirement Analisis:
1)Incremental data backup per day ( Cumulative or Difference backup ) ;
2)Month or Year or Week based daily? the week based daily should be chose ;
3)Sun(level 0)-Mon(level 1)-Tue(level 1)-Wes(level 1)-Thu(level 1)-Fri(level 1)-Sat(level 1)-Sun((level 0 again) ;
4)Automatically delete the expired backup files previous level 0 backup ;
5) Backup for the archive log accordingly .
How to implement it:
prepare for the scripts(Level 0 backup script and Level 1 backup script) ;
export ORACLE_SID
export ORACLE_HOME
export TBS_LOCATION
export RMAN_LOG
stty erase ^H
rman target / smglog $MAN_LOG append <<EOF
run{
allocate channel CH1 type disk;
allocate channel CH2 type disk;
backup tablespace users incremental level=0 format $TBS_LOCATION//$N_%s_%t.bak;
(backup tablespace users incremental level=1 format $TBS_LOCATION//$N_%s_%t.bak;)
(
exec >>backup_level11.og
rman catalog rman/rman1@orcl tareget / <<EOF
backup incremental level=1 database;
crosscheck backup;
delete expired backup;
exit;
EOF
)
sql 'alter system arvhive log current'
release channel CH1;
release channel CH2;
}
delete noprompt obosolete;//related with redunency number; the outnumbered backup will be marked as obselete
delete noprompt expired backup ;//
EOF
mailx -s "RMAN BAKUP USER TBLESPACE" yourmain@itf.com.cn<$RMAN_LOG
crontab -e 30 23 * * 0 /script
crontab -e 30 23 * * 1-6 /script
RMAN Image Copy
per se it is just a direct copy of all the related database files and quite efficent in recovering. it is not appropriate for big volumn database; it also support incremental backup.
allocate channel;
backup database as copy;
release channel;
<list copy> is used to check the rman image copy; <delete copy> is used to delete.