RMAN提供了DELETE ALL INPUT参数,加在BACKUP命令后,则会在完成备份后自动删除归档目录中已备份的归档日志(即会产生一个归档日志的备份文件,但是归档日志会被删除)。如果备份文件不丢失的话,则不会导致数据丢失。
查看backup archivelog all DELETE ALL INPUT产生的效果,及是否会导致数据丢失
--备注:本环境已做了全备
[oracle@source_pc rmanbk]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Tue Oct 14 03:23:43 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: ORCL (DBID=1378653027) RMAN> list archivelog all; using target database control file instead of recovery catalog List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - --------- ---- 16 1 20 A 14-OCT-14 /disk/archfile/1_20_851531816.dbf 17 1 21 A 14-OCT-14 /disk/archfile/1_21_851531816.dbf 18 1 22 A 14-OCT-14 /disk/archfile/1_22_851531816.dbf 19 1 23 A 14-OCT-14 /disk/archfile/1_23_851531816.dbf 20 1 24 A 14-OCT-14 /disk/archfile/1_24_851531816.dbf 21 1 25 A 14-OCT-14 /disk/archfile/1_25_851531816.dbf 22 1 26 A 14-OCT-14 /disk/archfile/1_26_851531816.dbf 23 1 27 A 14-OCT-14 /disk/archfile/1_27_851531816.dbf 24 1 28 A 14-OCT-14 /disk/archfile/1_28_851531816.dbf
RMAN> backup archivelog all delete all input; Starting backup at 14-OCT-14 current log archived allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=144 devtype=DISK channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=20 recid=16 stamp=860895472 input archive log thread=1 sequence=21 recid=17 stamp=860898658 input archive log thread=1 sequence=22 recid=18 stamp=860898896 input archive log thread=1 sequence=23 recid=19 stamp=860899177 input archive log thread=1 sequence=24 recid=20 stamp=860899314 input archive log thread=1 sequence=25 recid=21 stamp=860899907 input archive log thread=1 sequence=26 recid=22 stamp=860900262 input archive log thread=1 sequence=27 recid=23 stamp=860900381 input archive log thread=1 sequence=28 recid=24 stamp=860900571 input archive log thread=1 sequence=29 recid=25 stamp=860901944 channel ORA_DISK_1: starting piece 1 at 14-OCT-14 channel ORA_DISK_1: finished piece 1 at 14-OCT-14 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2014_10_14/o1_mf_annnn_TAG20141014T032544_b3smzt7z_.bkp tag=TAG20141014T032544 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:16 channel ORA_DISK_1: deleting archive log(s) archive log filename=/disk/archfile/1_20_851531816.dbf recid=16 stamp=860895472 archive log filename=/disk/archfile/1_21_851531816.dbf recid=17 stamp=860898658 archive log filename=/disk/archfile/1_22_851531816.dbf recid=18 stamp=860898896 archive log filename=/disk/archfile/1_23_851531816.dbf recid=19 stamp=860899177 archive log filename=/disk/archfile/1_24_851531816.dbf recid=20 stamp=860899314 archive log filename=/disk/archfile/1_25_851531816.dbf recid=21 stamp=860899907 archive log filename=/disk/archfile/1_26_851531816.dbf recid=22 stamp=860900262 archive log filename=/disk/archfile/1_27_851531816.dbf recid=23 stamp=860900381 archive log filename=/disk/archfile/1_28_851531816.dbf recid=24 stamp=860900571 archive log filename=/disk/archfile/1_29_851531816.dbf recid=25 stamp=860901944 Finished backup at 14-OCT-14
RMAN> list archivelog all; specification does not match any archive log in the recovery catalog --现在查看,归档日志都被删除了
SQL> select current_scn 2 from v$database; CURRENT_SCN ----------- 1219138 --t表现有数据: SQL> select * 2 from scott.t; ID ---------- 1 2 3 4 5 6 7 8 9 9 rows selected. SQL> delete 2 from scott.t 3 where id in (8,9); 2 rows deleted. SQL> commit; Commit complete.
RMAN> run { 2> shutdown immediate; 3> startup mount; 4> set until scn 1219138; 5> restore database; 6> recover database; 7> alter database open resetlogs; 8> } database closed database dismounted Oracle instance shut down connected to target database (not started) Oracle instance started database mounted Total System Global Area 285212672 bytes Fixed Size 1218992 bytes Variable Size 83887696 bytes Database Buffers 197132288 bytes Redo Buffers 2973696 bytes executing command: SET until clause Starting restore at 14-OCT-14 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=157 devtype=DISK channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf restoring datafile 00006 to /u01/app/oracle/oradata/orcl/test01.dbf restoring datafile 00007 to /u01/app/oracle/oradata/orcl/undo_test01.dbf restoring datafile 00009 to /u01/app/oracle/oradata/orcl/ogg01.dbf channel ORA_DISK_1: reading from backup piece /home/oracle/dandan/rmanbk/ORCL_20141014_1.bak channel ORA_DISK_1: restored backup piece 1 piece handle=/home/oracle/dandan/rmanbk/ORCL_20141014_1.bak tag=TAG20141014T012302 channel ORA_DISK_1: restore complete, elapsed time: 00:00:16 channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00008 to /u01/app/oracle/oradata/orcl/TEST02.DBF channel ORA_DISK_1: reading from backup piece /home/oracle/dandan/rmanbk/ORCL_20141014_2.bak channel ORA_DISK_1: restored backup piece 1 piece handle=/home/oracle/dandan/rmanbk/ORCL_20141014_2.bak tag=TAG20141014T012302 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 14-OCT-14 Starting recover at 14-OCT-14 using channel ORA_DISK_1 starting media recovery channel ORA_DISK_1: starting archive log restore to default destination channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=17 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=18 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=19 channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2014_10_14/o1_mf_annnn_TAG20141014T013247_b3sfczf7_.bkp channel ORA_DISK_1: restored backup piece 1 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2014_10_14/o1_mf_annnn_TAG20141014T013247_b3sfczf7_.bkp tag=TAG20141014T013247 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 archive log filename=/disk/archfile/1_17_851531816.dbf thread=1 sequence=17 archive log filename=/disk/archfile/1_18_851531816.dbf thread=1 sequence=18 archive log filename=/disk/archfile/1_19_851531816.dbf thread=1 sequence=19 channel ORA_DISK_1: starting archive log restore to default destination channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=20 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=21 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=22 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=23 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=24 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=25 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=26 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=27 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=28 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=29 channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2014_10_14/o1_mf_annnn_TAG20141014T032544_b3smzt7z_.bkp channel ORA_DISK_1: restored backup piece 1 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2014_10_14/o1_mf_annnn_TAG20141014T032544_b3smzt7z_.bkp tag=TAG20141014T032544 channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 archive log filename=/disk/archfile/1_20_851531816.dbf thread=1 sequence=20 archive log filename=/disk/archfile/1_21_851531816.dbf thread=1 sequence=21 archive log filename=/disk/archfile/1_22_851531816.dbf thread=1 sequence=22 archive log filename=/disk/archfile/1_23_851531816.dbf thread=1 sequence=23 archive log filename=/disk/archfile/1_24_851531816.dbf thread=1 sequence=24 archive log filename=/disk/archfile/1_25_851531816.dbf thread=1 sequence=25 archive log filename=/disk/archfile/1_26_851531816.dbf thread=1 sequence=26 archive log filename=/disk/archfile/1_27_851531816.dbf thread=1 sequence=27 media recovery complete, elapsed time: 00:00:20 Finished recover at 14-OCT-14 database opened RMAN>
SQL> select * 2 from t; ID ---------- 1 2 3 4 5 6 7 8 9 9 rows selected. --说明delete all input参数虽然会把备份过的归档日志删除掉,但是同样可以利用归档日志的备份文件将数据恢复回来