Files generated by RMAN can be either :
- an image copy (strict binary copy of database files)
- a set of backupsets (a set of binary files that contains severals pieces of the database). The backupset does not contains empty blocks or blocks allocated over the High Water Mark.
How to backup the entire database as backupsets
To backup the database as a backupset you can issue the following command:
$> export ORACLE_SID=TEST $> rman target / catalog rcatowner/rcatowner@rcat_db RMAN> BACKUP AS BACKUPSET database; Starting backup at 10-NOV-11 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/database/TEST/system/system01.dbf input datafile file number=00005 name=/database/TEST/rcat/rcat01.dbf input datafile file number=00002 name=/database/TEST/system/sysaux01.dbf input datafile file number=00003 name=/database/TEST/undo/undotbs01.dbf channel ORA_DISK_1: starting piece 1 at 10-NOV-11 channel ORA_DISK_1: finished piece 1 at 10-NOV-11 piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T104845_7cq7hxmg_.bkp tag=TAG20111110T104845 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/database/TEST/users/users01.dbf channel ORA_DISK_1: starting piece 1 at 10-NOV-11 channel ORA_DISK_1: finished piece 1 at 10-NOV-11 piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T104845_7cq7kbgs_.bkp tag=TAG20111110T104845 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting full 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 10-NOV-11 channel ORA_DISK_1: finished piece 1 at 10-NOV-11 piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_ncsnf_TAG20111110T104845_7cq7kgol_.bkp tag=TAG20111110T104845 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 10-NOV-11All datafiles, controlfiles and associated spfile are backuped as a backupset.
You can list the backupset to see its content :
RMAN> list backupset; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 2661 Full 1.19G DISK 00:00:41 10-NOV-11 BP Key: 2664 Status: AVAILABLE Compressed: NO Tag: TAG20111110T104845 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T104845_7cq7hxmg_.bkp List of Datafiles in backup set 2661 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 5141811 10-NOV-11 /database/TEST/system/system01.dbf 2 Full 5141811 10-NOV-11 /database/TEST/system/sysaux01.dbf 3 Full 5141811 10-NOV-11 /database/TEST/undo/undotbs01.dbf 5 Full 5141811 10-NOV-11 /database/TEST/rcat/rcat01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 2662 Full 33.46M DISK 00:00:01 10-NOV-11 BP Key: 2665 Status: AVAILABLE Compressed: NO Tag: TAG20111110T104845 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T104845_7cq7kbgs_.bkp List of Datafiles in backup set 2662 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 5141833 10-NOV-11 /database/TEST/users/users01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 2663 Full 9.61M DISK 00:00:01 10-NOV-11 BP Key: 2666 Status: AVAILABLE Compressed: NO Tag: TAG20111110T104845 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_ncsnf_TAG20111110T104845_7cq7kgol_.bkp SPFILE Included: Modification time: 10-NOV-11 SPFILE db_unique_name: TEST Control File Included: Ckp SCN: 5141834 Ckp time: 10-NOV-11Note that the type of the backup is FULL and performed on the disk.
You can check that no images copies are generated:
RMAN> list copy; specification does not match any datafile copy in the repository specification does not match any control file copy in the repository specification does not match any archived log in the repository
remark: You can delete the backupset using the following commands
RMAN> delete backupset 2661,2662,2663; using channel ORA_DISK_1 List of Backup Pieces BP Key BS Key Pc# Cp# Status Device Type Piece Name ------- ------- --- --- ----------- ----------- ---------- 2664 2661 1 1 AVAILABLE DISK /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T104845_7cq7hxmg_.bkp 2665 2662 1 1 AVAILABLE DISK /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T104845_7cq7kbgs_.bkp 2666 2663 1 1 AVAILABLE DISK /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_ncsnf_TAG20111110T104845_7cq7kgol_.bkp Do you really want to delete the above objects (enter YES or NO)? y deleted backup piece backup piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T104845_7cq7hxmg_.bkp RECID=33 STAMP=766838925 deleted backup piece backup piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T104845_7cq7kbgs_.bkp RECID=34 STAMP=766838970 deleted backup piece backup piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_ncsnf_TAG20111110T104845_7cq7kgol_.bkp RECID=35 STAMP=766838974 Deleted 3 objectsor using the Tag value
RMAN> delete backupset Tag 'TAG20111110T104845';
remark: You can overwrite the tag like this
RMAN> backup as backupset database tag 'MY_FIRST_BACKUP';and check the tag value
RMAN> list backupset summary; List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag ------- -- -- - ----------- --------------- ------- ------- ---------- --- 2833 B F A DISK 10-NOV-11 1 1 NO MY_FIRST_BACKUP 2834 B F A DISK 10-NOV-11 1 1 NO MY_FIRST_BACKUP 2835 B F A DISK 10-NOV-11 1 1 NO MY_FIRST_BACKUP
remark: You can also backup all the archive log in the same time of the database:
RMAN> backup as backupset database plus archivelog; ... RMAN> list backupset; List of Backup Sets =================== BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 586 73.50K DISK 00:00:00 10-NOV-11 BP Key: 590 Status: AVAILABLE Compressed: NO Tag: TAG20111110T114303 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_annnn_TAG20111110T114303_7cqboq9j_.bkp List of Archived Logs in backup set 586 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 260 5144748 10-NOV-11 5145114 10-NOV-11 1 261 5145114 10-NOV-11 5145118 10-NOV-11 1 262 5145118 10-NOV-11 5145125 10-NOV-11 1 263 5145125 10-NOV-11 5145128 10-NOV-11 1 264 5145128 10-NOV-11 5145131 10-NOV-11 1 265 5145131 10-NOV-11 5145199 10-NOV-11 BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 587 Full 1.19G DISK 00:00:45 10-NOV-11 BP Key: 591 Status: AVAILABLE Compressed: NO Tag: TAG20111110T114304 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T114304_7cqborsw_.bkp List of Datafiles in backup set 587 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 5145217 10-NOV-11 /database/TEST/system/system01.dbf 2 Full 5145217 10-NOV-11 /database/TEST/system/sysaux01.dbf 3 Full 5145217 10-NOV-11 /database/TEST/undo/undotbs01.dbf 5 Full 5145217 10-NOV-11 /database/TEST/rcat/rcat01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 588 Full 33.46M DISK 00:00:02 10-NOV-11 BP Key: 592 Status: AVAILABLE Compressed: NO Tag: TAG20111110T114304 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T114304_7cqbq5sc_.bkp List of Datafiles in backup set 588 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 5145240 10-NOV-11 /database/TEST/users/users01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 589 Full 9.67M DISK 00:00:02 10-NOV-11 BP Key: 593 Status: AVAILABLE Compressed: NO Tag: TAG20111110T114304 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_ncsnf_TAG20111110T114304_7cqbqb0p_.bkp SPFILE Included: Modification time: 10-NOV-11 SPFILE db_unique_name: TEST Control File Included: Ckp SCN: 5145241 Ckp time: 10-NOV-11 BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 613 7.00K DISK 00:00:00 10-NOV-11 BP Key: 616 Status: AVAILABLE Compressed: NO Tag: TAG20111110T114356 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_annnn_TAG20111110T114356_7cqbqdhm_.bkp List of Archived Logs in backup set 613 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 266 5145199 10-NOV-11 5145247 10-NOV-11remark: You can also delete all archived log after they have been backuped:
RMAN> backup as bacupset database plus archivelog delete input;
How to backup the entire database as image copies
To backup the database as image copy use the following command:
RMAN> backup as copy database; Starting backup at 10-NOV-11 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/database/TEST/system/system01.dbf output file name=/database/TEST/flash_recovery_area/TEST/datafile/o1_mf_system_7cqcc9jo_.dbf tag=TAG20111110T115433 RECID=18 STAMP=766842890 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=/database/TEST/system/sysaux01.dbf output file name=/database/TEST/flash_recovery_area/TEST/datafile/o1_mf_sysaux_7cqcd2th_.dbf tag=TAG20111110T115433 RECID=19 STAMP=766842916 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/database/TEST/undo/undotbs01.dbf output file name=/database/TEST/flash_recovery_area/TEST/datafile/o1_mf_undotbs1_7cqcdvz1_.dbf tag=TAG20111110T115433 RECID=20 STAMP=766842927 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/database/TEST/users/users01.dbf output file name=/database/TEST/flash_recovery_area/TEST/datafile/o1_mf_users_7cqcf30k_.dbf tag=TAG20111110T115433 RECID=21 STAMP=766842932 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy input datafile file number=00005 name=/database/TEST/rcat/rcat01.dbf output file name=/database/TEST/flash_recovery_area/TEST/datafile/o1_mf_rcat_ts_7cqcf64t_.dbf tag=TAG20111110T115433 RECID=22 STAMP=766842934 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting datafile copy copying current control file output file name=/database/TEST/flash_recovery_area/TEST/controlfile/o1_mf_TAG20111110T115433_7cqcf79c_.ctl tag=TAG20111110T115433 RECID=23 STAMP=766842935 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 10-NOV-11 channel ORA_DISK_1: finished piece 1 at 10-NOV-11 piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnsnf_TAG20111110T115433_7cqcf8gw_.bkp tag=TAG20111110T115433 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 10-NOV-11You can check the image copy using:
RMAN> list copy; specification does not match any archived log in the repository List of Datafile Copies ======================= Key File S Completion Time Ckp SCN Ckp Time ------- ---- - --------------- ---------- --------------- 671 1 A 10-NOV-11 5145845 10-NOV-11 Name: /database/TEST/flash_recovery_area/TEST/datafile/o1_mf_system_7cqcc9jo_.dbf Tag: TAG20111110T115433 672 2 A 10-NOV-11 5145891 10-NOV-11 Name: /database/TEST/flash_recovery_area/TEST/datafile/o1_mf_sysaux_7cqcd2th_.dbf Tag: TAG20111110T115433 673 3 A 10-NOV-11 5145901 10-NOV-11 Name: /database/TEST/flash_recovery_area/TEST/datafile/o1_mf_undotbs1_7cqcdvz1_.dbf Tag: TAG20111110T115433 674 4 A 10-NOV-11 5145904 10-NOV-11 Name: /database/TEST/flash_recovery_area/TEST/datafile/o1_mf_users_7cqcf30k_.dbf Tag: TAG20111110T115433 675 5 A 10-NOV-11 5145906 10-NOV-11 Name: /database/TEST/flash_recovery_area/TEST/datafile/o1_mf_rcat_ts_7cqcf64t_.dbf Tag: TAG20111110T115433 List of Control File Copies =========================== Key S Completion Time Ckp SCN Ckp Time ------- - --------------- ---------- --------------- 677 A 10-NOV-11 5145906 10-NOV-11 Name: /database/TEST/flash_recovery_area/TEST/controlfile/o1_mf_TAG20111110T115433_7cqcf79c_.ctl Tag: TAG20111110T115433
remark: If you check for backupset, you will see that the SPFILE as been backuped as a backupset and not as an image copy.
RMAN> list backupset; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 667 Full 80.00K DISK 00:00:00 10-NOV-11 BP Key: 668 Status: AVAILABLE Compressed: NO Tag: TAG20111110T115433 Piece Name: /database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnsnf_TAG20111110T115433_7cqcf8gw_.bkp SPFILE Included: Modification time: 10-NOV-11 SPFILE db_unique_name: TEST
How to define a new location for backups
To define a specific location for backup destination, use the following syntax :
RMAN> BACKUP AS BACKUPSET FORMAT '/u01/oradata/backups/%F' database;
How to backup only a datafile
To backup only a datafile you can use the BACKUP DATAFILE syntax. First of all, you need to identify the datafile to backup either by its location in the file system or it identifier.
a) by the datafile id
RMAN> report schema; Report of database schema for database with db_unique_name TEST List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 760 SYSTEM YES /database/TEST/system/system01.dbf 2 730 SYSAUX NO /database/TEST/system/sysaux01.dbf 3 100 UNDOTBS1 YES /database/TEST/undo/undotbs01.dbf 4 37 USERS NO /database/TEST/users/users01.dbf 5 15 RCAT_TS NO /database/TEST/rcat/rcat01.dbf List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name ---- -------- -------------------- ----------- -------------------- 1 43 TEMP 32767 /database/TEST/temp/temp01.dbf RMAN> backup as backupset datafile 4 Starting backup at 10-NOV-11 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/database/TEST/users/users01.dbf channel ORA_DISK_1: starting piece 1 at 10-NOV-11 channel ORA_DISK_1: finished piece 1 at 10-NOV-11 piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T143410_7cqnpl6d_.bkp tag=TAG20111110T143410 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 10-NOV-11 ;or using a file name
RMAN> backup as backupset datafile '/database/TEST/users/users01.dbf'; Starting backup at 10-NOV-11 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/database/TEST/users/users01.dbf channel ORA_DISK_1: starting piece 1 at 10-NOV-11 channel ORA_DISK_1: finished piece 1 at 10-NOV-11 piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T143720_7cqnwk2r_.bkp tag=TAG20111110T143720 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 10-NOV-11How to backup a tablespace
To backup only a tablespace you can use the BACKUP TABLESPACE syntax.
RMAN> BACKUP AS BACKUPSET TABLESPACE USERS; Starting backup at 10-NOV-11 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/database/TEST/users/users01.dbf channel ORA_DISK_1: starting piece 1 at 10-NOV-11 channel ORA_DISK_1: finished piece 1 at 10-NOV-11 piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_nnndf_TAG20111110T144000_7cqo1jtn_.bkp tag=TAG20111110T144000 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 10-NOV-11How to backup archivelog
RMAN> backup as backupset archivelog all; Starting backup at 10-NOV-11 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=267 RECID=89 STAMP=766852984 channel ORA_DISK_1: starting piece 1 at 10-NOV-11 channel ORA_DISK_1: finished piece 1 at 10-NOV-11 piece handle=/database/TEST/flash_recovery_area/TEST/backupset/2011_11_10/o1_mf_annnn_TAG20111110T144305_7cqo79b4_.bkp tag=TAG20111110T144305 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 10-NOV-11or
RMAN> backup as copy archivelog all; Starting backup at 10-NOV-11 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=267 RECID=89 STAMP=766852984 output file name=/database/TEST/flash_recovery_area/TEST/archivelog/2011_11_10/o1_mf_1_267_7cqocxbx_.arc RECID=91 STAMP=766853133 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=268 RECID=90 STAMP=766853132 output file name=/database/TEST/flash_recovery_area/TEST/archivelog/2011_11_10/o1_mf_1_268_7cqocyh3_.arc RECID=92 STAMP=766853134 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 Finished backup at 10-NOV-11
If you need to backup a specific archive log, you can write :
RAMN> backup as copy archivelog like '/database/TEST/flash_recovery_area/TEST/archivelog/2011_11_10/o1_mf_1_269_7cqok20g_.arc'; Starting backup at 10-NOV-11 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=145 device type=DISK channel ORA_DISK_1: starting archived log copy input archived log thread=1 sequence=269 RECID=93 STAMP=766853298 output file name=/database/TEST/flash_recovery_area/TEST/archivelog/2011_11_10/o1_mf_1_269_7cqolrj4_.arc RECID=94 STAMP=766853352 channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 Finished backup at 10-NOV-11
How to perform incremental backups
The start point of an incremental backup must be a level 0 inrecemtal batabase backup. See here under to perform an incremental level 0 backup:
RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE:
Once an level 0 backup is perform, it is then possible to perform incremental backups. There are 2 types of incremental backups :
a) differential incremental backup
RMAN> backup incremental level 1 DATABASE;A differential incremental backup contains blocks that have change since the last incremental backup level 1 or 0, if it is the list incremental backup.
b) cummulative incremental backup
RMAN> backup incremental level 1 CUMULATIVE DATABASE;A cumulative backup contains blocks that have changed since the level 0 backup;
remark: to speed up the incremental backups, it is possible to activate a block change tracking feature that will trace into a file all blocks that have changed since the last backup. To do this, you can use the following syntax :
SQL> ALTER DATABASE {ENABLE|DISABLE} BLOCK CHANGE TRACKING [USING FILE '...'] [REUSE];
How to perform backups with multisections
To optimize backup for big files, it will be possible to backup file using the multi section feature. In this way, we can cut up the big files in severals smallest ones that could be backed up in parallel through multiple channels allocations or parallelism.
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 4; RMAN> BACKUP as backupset INCREMENTAL LEVEL 0 DATABASE SECTION SIZE=25M;or
RMAN> RUN { ALLOCATE CHANNEL disk1 device type disk; ALLOCATE CHANNEL disk2 device type disk; ALLOCATE CHANNEL disk3 device type disk; ALLOCATE CHANNEL disk4 device type disk; BACKUP as backupset DATABASE SECTION SIZE=25M; }