文档课题:image copy增量更新备份解析.
数据库:oracle 11.2.0.4
1、概念
当执行image copy的增量更新备份时,recover与backup每天的执行情况如下图所示:
语句:
recover copy of database with tag 'daily_inc';
backup incremental level 1 for recover of copy with tag 'daily_inc' database;
2、实际操作标签:datafile,DISK,04,image,oracle,app,copy,备份,u01 From: https://blog.51cto.com/u_12991611/6037272
2.1、第一天
RMAN> recover copy of database with tag 'daily_inc';
Starting recover at 04-FEB-23
using channel ORA_DISK_1
no copy of datafile 1 found to recover
no copy of datafile 2 found to recover
no copy of datafile 3 found to recover
no copy of datafile 4 found to recover
Finished recover at 04-FEB-23
RMAN> backup incremental level 1 for recover of copy with tag 'daily_inc' database;
Starting backup at 04-FEB-23
using channel ORA_DISK_1
no parent backup or copy of datafile 1 found
no parent backup or copy of datafile 2 found
no parent backup or copy of datafile 3 found
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl150/system01.dbf
output file name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_system_kxwg1hmq_.dbf tag=DAILY_INC RECID=2 STAMP=1127933365
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl150/sysaux01.dbf
output file name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_sysaux_kxwg1p5k_.dbf tag=DAILY_INC RECID=3 STAMP=1127933370
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl150/undotbs01.dbf
output file name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_undotbs1_kxwg1x7v_.dbf tag=DAILY_INC RECID=4 STAMP=1127933373
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-FEB-23
channel ORA_DISK_1: finished piece 1 at 04-FEB-23
piece handle=/u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_ncsn1_DAILY_INC_kxwg1zc1_.bkp tag=DAILY_INC comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl150/users01.dbf
output file name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_users_kxwg20gs_.dbf tag=DAILY_INC RECID=5 STAMP=1127933376
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 04-FEB-23
说明:recover为nothing,backup为create image copies.
2.2、第二天
RMAN> recover copy of database with tag 'daily_inc';
Starting recover at 04-FEB-23
using channel ORA_DISK_1
no copy of datafile 1 found to recover
no copy of datafile 2 found to recover
no copy of datafile 3 found to recover
no copy of datafile 4 found to recover
Finished recover at 04-FEB-23
RMAN> backup incremental level 1 for recover of copy with tag 'daily_inc' database;
Starting backup at 04-FEB-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl150/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl150/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl150/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl150/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-FEB-23
channel ORA_DISK_1: finished piece 1 at 04-FEB-23
piece handle=/u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_nnnd1_DAILY_INC_kxwgbd02_.bkp tag=DAILY_INC comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-FEB-23
channel ORA_DISK_1: finished piece 1 at 04-FEB-23
piece handle=/u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_ncsn1_DAILY_INC_kxwgbj23_.bkp tag=DAILY_INC comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-FEB-23
说明:recover为nothing,backup为create incremental level 1。
2.3、第三天
RMAN> recover copy of database with tag 'daily_inc';
Starting recover at 04-FEB-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00001 name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_system_kxwg1hmq_.dbf
recovering datafile copy file number=00002 name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_sysaux_kxwg1p5k_.dbf
recovering datafile copy file number=00003 name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_undotbs1_kxwg1x7v_.dbf
recovering datafile copy file number=00004 name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_users_kxwg20gs_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_nnnd1_DAILY_INC_kxwgbd02_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_nnnd1_DAILY_INC_kxwgbd02_.bkp tag=DAILY_INC
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 04-FEB-23
RMAN> backup incremental level 1 for recover of copy with tag 'daily_inc' database;
Starting backup at 04-FEB-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl150/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl150/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl150/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl150/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-FEB-23
channel ORA_DISK_1: finished piece 1 at 04-FEB-23
piece handle=/u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_nnnd1_DAILY_INC_kxwggdjl_.bkp tag=DAILY_INC comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-FEB-23
channel ORA_DISK_1: finished piece 1 at 04-FEB-23
piece handle=/u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_ncsn1_DAILY_INC_kxwggjlq_.bkp tag=DAILY_INC comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-FEB-23
说明:recover为recover copies based on incremental,backup为create incremental level 1。
3、备份情况
RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Incr 1 9.45M DISK 00:00:01 04-FEB-23
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: DAILY_INC
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_ncsn1_DAILY_INC_kxwg1zc1_.bkp
SPFILE Included: Modification time: 03-FEB-23
SPFILE db_unique_name: ORCL150
Control File Included: Ckp SCN: 1378709 Ckp time: 04-FEB-23
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Incr 1 248.00K DISK 00:00:03 04-FEB-23
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: DAILY_INC
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_nnnd1_DAILY_INC_kxwgbd02_.bkp
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 1 Incr 1379017 04-FEB-23 /u01/app/oracle/oradata/orcl150/system01.dbf
2 1 Incr 1379017 04-FEB-23 /u01/app/oracle/oradata/orcl150/sysaux01.dbf
3 1 Incr 1379017 04-FEB-23 /u01/app/oracle/oradata/orcl150/undotbs01.dbf
4 1 Incr 1379017 04-FEB-23 /u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_users_kxwg20gs_.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Incr 1 9.45M DISK 00:00:01 04-FEB-23
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: DAILY_INC
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_ncsn1_DAILY_INC_kxwgbj23_.bkp
SPFILE Included: Modification time: 03-FEB-23
SPFILE db_unique_name: ORCL150
Control File Included: Ckp SCN: 1379019 Ckp time: 04-FEB-23
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Incr 1 408.00K DISK 00:00:02 04-FEB-23
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: DAILY_INC
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_nnnd1_DAILY_INC_kxwggdjl_.bkp
List of Datafiles in backup set 6
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 1 Incr 1379272 04-FEB-23 /u01/app/oracle/oradata/orcl150/system01.dbf
2 1 Incr 1379272 04-FEB-23 /u01/app/oracle/oradata/orcl150/sysaux01.dbf
3 1 Incr 1379272 04-FEB-23 /u01/app/oracle/oradata/orcl150/undotbs01.dbf
4 1 Incr 1379272 04-FEB-23 /u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_users_kxwg20gs_.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7 Incr 1 9.45M DISK 00:00:01 04-FEB-23
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: DAILY_INC
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_ncsn1_DAILY_INC_kxwggjlq_.bkp
SPFILE Included: Modification time: 03-FEB-23
SPFILE db_unique_name: ORCL150
Control File Included: Ckp SCN: 1379274 Ckp time: 04-FEB-23
4、文件恢复
运用image copy备份进行数据文件恢复.
4.1、开始恢复
RMAN> sql "alter tablespace users offline";
sql statement: alter tablespace users offline
RMAN> switch datafile 4 to copy;
datafile 4 switched to datafile copy "/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_users_kxwg20gs_.dbf"
RMAN> recover datafile 4;
Starting recover at 04-FEB-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00004: /u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_users_kxwg20gs_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_nnnd1_DAILY_INC_kxwggdjl_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL150/backupset/2023_02_04/o1_mf_nnnd1_DAILY_INC_kxwggdjl_.bkp tag=DAILY_INC
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 04-FEB-23
RMAN> sql "alter tablespace users online";
sql statement: alter tablespace users online
RMAN> report schema;
Report of database schema for database with db_unique_name ORCL150
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 1240 SYSTEM *** /u01/app/oracle/oradata/orcl150/system01.dbf
2 570 SYSAUX *** /u01/app/oracle/oradata/orcl150/sysaux01.dbf
3 70 UNDOTBS1 *** /u01/app/oracle/oradata/orcl150/undotbs01.dbf
4 5 USERS *** /u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_users_kxwg20gs_.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 32767 /u01/app/oracle/oradata/orcl150/temp01.dbf
4.2、修改路径
--恢复后发现文件名以及路径未达到效果,现进行路径以及文件名的修改.
RMAN> backup as copy datafile 4 format '/u01/app/oracle/oradata/orcl150/users01.dbf' reuse;
Starting backup at 04-FEB-23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/fast_recovery_area/ORCL150/datafile/o1_mf_users_kxwg20gs_.dbf
output file name=/u01/app/oracle/oradata/orcl150/users01.dbf tag=TAG20230204T192043 RECID=12 STAMP=1127935243
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 04-FEB-23
RMAN> sql "alter tablespace users offline";
sql statement: alter tablespace users offline
RMAN> switch datafile 4 to copy;
datafile 4 switched to datafile copy "/u01/app/oracle/oradata/orcl150/users01.dbf"
RMAN> report schema;
Report of database schema for database with db_unique_name ORCL150
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 1240 SYSTEM *** /u01/app/oracle/oradata/orcl150/system01.dbf
2 570 SYSAUX *** /u01/app/oracle/oradata/orcl150/sysaux01.dbf
3 70 UNDOTBS1 *** /u01/app/oracle/oradata/orcl150/undotbs01.dbf
4 0 USERS *** /u01/app/oracle/oradata/orcl150/users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 32767 /u01/app/oracle/oradata/orcl150/temp01.dbf
RMAN> recover datafile 4;
Starting recover at 04-FEB-23
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 04-FEB-23
RMAN> sql "alter tablespace users online";
sql statement: alter tablespace users online
说明:该方法可用于改变数据文件目录.