Wednesday, November 4, 2009

Example of Incrementally Updated RMAN backups (start phase)

This example shows how RMAN marks the first incremental backup as '1' and not '0'. RMAN does not change the backup to become an incremental '0', as many people would think.


RMAN parameters

RMAN> show all;

RMAN configuration parameters for database with db_unique_name DB11G are:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/backup/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/opt/oracle/backup/DB11G_%U.rbk';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/11R1/dbs/snapcf_DB11G.f'; # default

RMAN> exit


Run the first incremental backup


[oracle@server backup]$ rman target /
Recovery Manager: Release 11.1.0.7.0 - Production on Thu Nov 5 00:31:57 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: DB11G (DBID=170286104)

RMAN> RUN
{
RECOVER COPY OF DATABASE
WITH TAG 'incr_update';
BACKUP
INCREMENTAL LEVEL 1
FOR RECOVER OF COPY WITH TAG 'incr_update'
DATABASE;
}2> 3> 4> 5> 6> 7> 8> 9>

Starting recover at 05-NOV-09
using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=937 device type=DISK
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
no copy of datafile 5 found to recover
Finished recover at 05-NOV-09
Starting backup at 05-NOV-09
using channel ORA_DISK_1

no parent backup or copy of datafile 2 found
no parent backup or copy of datafile 1 found
no parent backup or copy of datafile 3 found
no parent backup or copy of datafile 4 found
no parent backup or copy of datafile 5 found
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/opt/oracle/oradata/DB11G/sysaux01.dbf
output file name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-SYSAUX_FNO-2_09kti14r.rbk tag=INCR_UPDATE RECID=1 STAMP=702088421
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/opt/oracle/oradata/DB11G/system01.dbf
output file name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-SYSTEM_FNO-1_0akti176.rbk tag=INCR_UPDATE RECID=2 STAMP=702088479
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/opt/oracle/oradata/DB11G/undotbs01.dbf
output file name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-UNDOTBS1_FNO-3_0bkti197.rbk tag=INCR_UPDATE RECID=3 STAMP=702088530
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/opt/oracle/oradata/DB11G/example01.dbf
output file name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-EXAMPLE_FNO-4_0ckti1ak.rbk tag=INCR_UPDATE RECID=4 STAMP=702088544
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/opt/oracle/oradata/DB11G/users01.dbf
output file name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-USERS_FNO-5_0dkti1b4.rbk tag=INCR_UPDATE RECID=5 STAMP=702088548
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 05-NOV-09

Starting Control File and SPFILE Autobackup at 05-NOV-09
piece handle=/opt/oracle/backup/c-170286104-20091105-00 comment=NONE
Finished Control File and SPFILE Autobackup at 05-NOV-09
Recovery Manager complete.

Do some changes to the database

[oracle@server backup]$ dba
SQL*Plus: Release 11.1.0.7.0 - Production on Thu Nov 5 00:36:05 2009
Copyright (c) 1982, 2008, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table test (foo varchar2(10));

Table created.

SQL> insert into test values ('testing');

1 row created.

SQL> commit;

Commit complete.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Run another incrementally updated backup


[oracle@server backup]$ rman target /
Recovery Manager: Release 11.1.0.7.0 - Production on Thu Nov 5 00:38:09 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: DB11G (DBID=170286104)

RMAN> RUN
{
RECOVER COPY OF DATABASE
WITH TAG 'incr_update';
BACKUP
INCREMENTAL LEVEL 1
FOR RECOVER OF COPY WITH TAG 'incr_update'
DATABASE;
}2> 3> 4> 5> 6> 7> 8> 9>

Starting recover at 05-NOV-09
using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=963 device type=DISK
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
no copy of datafile 5 found to recover
Finished recover at 05-NOV-09

Starting backup at 05-NOV-09

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=00002 name=/opt/oracle/oradata/DB11G/sysaux01.dbf
input datafile file number=00001 name=/opt/oracle/oradata/DB11G/system01.dbf
input datafile file number=00003 name=/opt/oracle/oradata/DB11G/undotbs01.dbf
input datafile file number=00004 name=/opt/oracle/oradata/DB11G/example01.dbf
input datafile file number=00005 name=/opt/oracle/oradata/DB11G/users01.dbf
channel ORA_DISK_1: starting piece 1 at 05-NOV-09
channel ORA_DISK_1: finished piece 1 at 05-NOV-09
piece handle=/opt/oracle/backup/DB11G_0fkti1g6_1_1.rbk tag=TAG20091105T003830 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 05-NOV-09

Starting Control File and SPFILE Autobackup at 05-NOV-09
piece handle=/opt/oracle/backup/c-170286104-20091105-01 comment=NONE
Finished Control File and SPFILE Autobackup at 05-NOV-09

RMAN> exit
Recovery Manager complete.

Do more updated to the database

[oracle@server backup]$ dba
SQL*Plus: Release 11.1.0.7.0 - Production on Thu Nov 5 00:38:58 2009
Copyright (c) 1982, 2008, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> insert into test values ('testing2');

1 row created.

SQL> commit;

Commit complete.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Run the third incrementally updated backup


[oracle@server backup]$ rman target /
Recovery Manager: Release 11.1.0.7.0 - Production on Thu Nov 5 00:39:31 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: DB11G (DBID=170286104)

RMAN> RUN
{
RECOVER COPY OF DATABASE
WITH TAG 'incr_update';
BACKUP
INCREMENTAL LEVEL 1
FOR RECOVER OF COPY WITH TAG 'incr_update'
DATABASE;
}2> 3> 4> 5> 6> 7> 8> 9>

Starting recover at 05-NOV-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=946 device type=DISK
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=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-SYSTEM_FNO-1_0akti176.rbk
recovering datafile copy file number=00002 name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-SYSAUX_FNO-2_09kti14r.rbk
recovering datafile copy file number=00003 name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-UNDOTBS1_FNO-3_0bkti197.rbk
recovering datafile copy file number=00004 name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-EXAMPLE_FNO-4_0ckti1ak.rbk
recovering datafile copy file number=00005 name=/opt/oracle/backup/DB11G_data_D-DB11G_I-170286104_TS-USERS_FNO-5_0dkti1b4.rbk
channel ORA_DISK_1: reading from backup piece /opt/oracle/backup/DB11G_0fkti1g6_1_1.rbk
channel ORA_DISK_1: piece handle=/opt/oracle/backup/DB11G_0fkti1g6_1_1.rbk tag=TAG20091105T003830
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished recover at 05-NOV-09

Starting backup at 05-NOV-09
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=00002 name=/opt/oracle/oradata/DB11G/sysaux01.dbf
input datafile file number=00001 name=/opt/oracle/oradata/DB11G/system01.dbf
input datafile file number=00003 name=/opt/oracle/oradata/DB11G/undotbs01.dbf
input datafile file number=00004 name=/opt/oracle/oradata/DB11G/example01.dbf
input datafile file number=00005 name=/opt/oracle/oradata/DB11G/users01.dbf
channel ORA_DISK_1: starting piece 1 at 05-NOV-09
channel ORA_DISK_1: finished piece 1 at 05-NOV-09
piece handle=/opt/oracle/backup/DB11G_0hkti1ih_1_1.rbk tag=TAG20091105T003944 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 05-NOV-09

Starting Control File and SPFILE Autobackup at 05-NOV-09
piece handle=/opt/oracle/backup/c-170286104-20091105-02 comment=NONE
Finished Control File and SPFILE Autobackup at 05-NOV-09

RMAN> exit
Recovery Manager complete.

Report the INCREMENTAL_LEVEL from V$BACKUP_SET
[oracle@server backup]$ dba
SQL*Plus: Release 11.1.0.7.0 - Production on Thu Nov 5 00:39:55 2009
Copyright (c) 1982, 2008, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> r
1 select START_TIME, BACKUP_TYPE, INCREMENTAL_LEVEL
2 from v$backup_set
3 where start_time > sysdate-1
4* order by 1

START_TIME B INCREMENTAL_LEVEL
-------------------- - -----------------
05-NOV-2009 00:35:49 D
05-NOV-2009 00:38:30 I 1
05-NOV-2009 00:38:33 D
05-NOV-2009 00:39:45 I 1
05-NOV-2009 00:39:48 D

As you can see. The level has not changed to '0' by Oracle RMAN, even though this was the start of an incrementally updated backup.