rman大全

rman大全

发表人:vongates | 发表时间: 2005年二月25日, 23:11

1:to back the controlfile using rman
备份控制文件
run{
allocate channel dev1 type disk format 'c:backup%U';
backup current controlfile;
}

2:to check the backup of controlfile using rman:
检查备份的控制文件
list backup of controlfile;

3:to recover using backup controlfile(startup nomount)
恢复控制文件
run {
allocate channel dev1 type disk;
restore controlfile;
alter database mount;
restore database;
recover database;
sql "ALTER DATABASE OPEN RESETLOGS"
}

4:backup all datafile and controlfile using rman:
备份所有的数据文件和控制文件
run {
allocate channel dev1 type disk;
backup full tag = 'full backup' database include current controlfile format = 'c:backupdb_t%t_s%s_p%p';
release channel dev1;
}

5:check all backup of datafiles using rman:
检查所有的数据文件和控制文件
list backupset;

6:to restore because of missing file(first mount the database and run RMAN)
因文件丢失而修复
run {
allocate channel dev1 type disk;
restore database;
recover database;
}

7:restore until time
恢复到某个时间点
The 'SET UNTIL TIME' must match with the variable NLS_DATE_FORMAT.
Prior logging on RMAN set the NLS_DATE_FORMAT in the desired format.
For example:
If unix ===> export NLS_DATE_FORMAT='YYYY-MM-DD:HH24:MI:SS';
If on windows nt ===> set this vaiable in the registery.
run {
set until time 'May 1 2000 08:00:00';
allocate channel dev1 type disk;
shutdown abort;
startup nomount;
restore controlfile;
alter database mount;
restore database;
recover database;
sql 'alter database open resetlogs';
}

8:to purge obsolete backups:
清除旧的备份
report obsolete redundancy 3 device type disk; #REPORTS ANY BACKUP WITH MORE THAN 3 COPIES
report obsolete orphan; #USE THIS REPORT TO FILL IN THE XXXXX BELOW

run {
allocate channel for maintenance type disk;
allocate channel for delete type disk;
change backuppiece 'C:BACKUPxxxx' delete;
release channel;

run {
allocate channel for maintenance type disk;
allocate channel for delete type disk;
change datafilecopy 'C:BACKUPxxxx' delete;
release channel;

9:to backup all archive logs
备份所有的归档日志
run{
allocate channel dev1 type disk format 'c:backup%U';
backup archivelog all;
}

10:to remove all archive log files alter backup update to this line

backup archivelog all delete input;

11:skip an archive log file that can not be read or manualy deleted update to this line
backup archivelog skip inaccessible /inaccessible不可存取

12:to remove one archive log that you manualy deleted and now get an rman-6089<=8.0
allocate channel for delete type disk; or 'SBT_TAPE';
change archivelog 'path/filename' delete;
and/or
resync catalog;

13:to remove one archive log that you manualy deleted and now get an rman-6089<=8.1
allocate channel for maintenance type ....'
change archivelog <name> uncatalog

replace script backup_db_full {
#
# Backs up the whole database into backup-sets. This backup is not part
execute script alloc_all_tapes;
execute script set_maxcorrupt;
backup
full
# skip offline
# skip readonly
skip inaccessible
tag b_db_full
filesperset 6
format 'df_t%t_s%s_p%p'
database;
execute script rel_all_tapes;
execute script archive_log_current;
execute script backup_al_all;
}

replace script backup_db_level_0 {
#
# Backs up the whole database. This backup is part of the incremental
# strategy.
# It performs exactly the same backup as the script backup above, except
# the datafile backup is part of the incremental strategy (this means it
# can have incremental backups of levels > 0 applied to it - full backups
# cannot).
#
# Typically, a level 0 backup would be done at least once a week.
#
# Modified By Reason
# 961219 cd created
#
execute script alloc_all_tapes;
execute script set_maxcorrupt;
backup
incremental level 0
# skip offline
# skip readonly
skip inaccessible
tag backup_db_level_0
filesperset 6
format 'df_t%t_s%s_p%p'
database;
execute script rel_all_tapes;
execute script archive_log_current;
execute script backup_al_all;
}

replace script backup_db_level_1 {
#
# This backup will only backup blocks which have been modified since the
# last level 0 backup was performed. Otherwise it is exactly the same
# backup as the level 0 above (note, the controlfile is always backed up in
# it's entirety i.e. control file backups are never compressed).
#
# Typically, a level 1 backup would be done at least once in between level
# 0 backups.
#
# Modified By Reason
# 961219 cd created
#
execute script alloc_all_tapes;
execute script set_maxcorrupt;
backup
incremental level 1
# skip offline
# skip readonly
skip inaccessible
tag backup_db_level_1
filesperset 6
format 'df_t%t_s%s_p%p'
database;
execute script rel_all_tapes;
execute script archive_log_current;
execute script backup_al_all;
}

replace script backup_db_level_2 {
#
# This backup will only backup blocks which have been modified since the
# last level 0 or 1 backup was performed. Otherwise it is exactly the same
# backup as the level 0 or 1 backups above.
#
# Typically, a level 2 backup would be done at least once in between level
# 0 and 1 backups.
#
# Modified By Reason
# 961219 cd created
#
execute script alloc_all_tapes;
execute script set_maxcorrupt;
backup
incremental level 2
# skip offline
# skip readonly
skip inaccessible
tag backup_db_level_2
filesperset 6
format 'df_t%t_s%s_p%p'
database;
execute script rel_all_tapes;
execute script archive_log_current;
execute script backup_al_all;
}

原文地址:https://www.cnblogs.com/O/p/284603.html