RMAN备份
备份控制文件:
run{
allocate channel dev1 type disk format ‘/usr/oracle/boson/backup_control%U’;
backup current controlfile;
}
检查备份的控制文件
list backup of controlfile
RMAN> list backup of controlfile;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
25 Full 6.80M DISK 00:00:01 21-NOV-07
BP Key: 25 Status: AVAILABLE Compressed: NO Tag: TAG20071121T112225
Piece Name: /usr/oracle/boson/backup_control0sj1jm7i_1_1
Control File Included: Ckp SCN: 12536946 Ckp time: 21-NOV-07
3:用备份的控制文件恢复(startup nomount)
恢复控制文件
run {
allocate channel dev1 type disk;
restore controlfile;
alter database mount;
restore database;
recover database;
sql “ALTER DATABASE OPEN RESETLOGS”
}
4.备份所有的数据文件和控制文件
run {
allocate channel dev1 type disk;
backup full tag = ‘full backup’ database include current controlfile format = ‘/usr/oracle/boson/backupdb_t%t_s%s_p%p’;
release channel dev1;
}
5.检查所有的数据文件和控制文件
list backupset;
list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
9 Full 1.02G DISK 00:04:50 10-OCT-07
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: BOSON
Piece Name: /usr/oracle/flash_recovery_area/ORCL/bosonfull_ORCL_20071010_10
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
—- — —- ———- ——— —-
1 Full 10568570 10-OCT-07 /usr/oracle/oradata/orcl/system01.dbf
2 Full 10568570 10-OCT-07 /usr/oracle/oradata/orcl/undotbs01.dbf
3 Full 10568570 10-OCT-07 /usr/oracle/oradata/orcl/sysaux01.dbf
4 Full 10568570 10-OCT-07 /usr/oracle/oradata/orcl/users01.dbf
5 Full 10568570 10-OCT-07 /usr/oracle/oradata/orcl/game01.dbf
6 Full 10568570 10-OCT-07 /usr/oracle/oradata/orcl/idx_game_01.dbf
7 Full 10568570 10-OCT-07 /usr/oracle/oradata/orcl/data01.dbf
8 Full 10568570 10-OCT-07 /usr/oracle/oradata/orcl/tradelog01.dbf
9 Full 10568570 10-OCT-07
6:文件丢失恢复(数据启动到mount状态and run RMAN)
因文件丢失而修复
run {
allocate channel dev1 type disk;
restore database;
recover database;
}
7:恢复到某个时间点
设置的’SET UNTIL TIME’ 格式必须和NLS_DATE_FORMAT的格式一致
设置时间格式方法如下:
UNIX下是
export NLS_DATE_FORMAT=’YYYY-MM-DD:HH24:MI:SS’;
run {
set until time ‘NOV 21 2007 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:清除旧的备份
report obsolete redundancy 3 device type disk; #REPORTS ANY BACKUP WITH MORE THAN 3 COPIES
delete obsolete
9:备份所有的归档日志
run{
allocate channel dev1 type disk format ‘/usr/oracle/boson/backup_arch%U’;
backup archivelog all;
backup archivelog all delete input;
}
