********************************************************
* Description: Knowledge of Oracle backup set and piece
* Date: 04:59 PM EST, 07/21/2017
********************************************************



<1> Backup set:
     |
     |__ o. RMAN can store backup data in a logical structure called a backup set, which is the smallest unit of an RMAN backup. 
            A backup set contains the data from one or more datafiles, archived redo logs, or control files or server parameter file. 
            Backup sets, which are only created and accessed through RMAN, are the only form in which RMAN can write backups to media managers such as tape drives and tape libraries.
                                                                            
			
			
<2> Backup piece:
     |
     |__ o. A backup set contains one or more binary files in an RMAN-specific format. This file is known as a backup piece.

	 

<3> Image copy:
     |
     |__ o. An image copy is an exact copy of a single datafile, archived redo log file, or control file.
            Image copies are not stored in an RMAN-specific format. They are identical to the results of copying a file with operating system commands.	 

	 
	 
<4> Summary:	 
     |
     |__ o. Backup set is a LOGICAL concept. Each backup set is like a notebook recording what data files, archived logs, spfile, or control file it contains.	
     |      Empty blocks within data file will not be backed up into backup set.	 
     |      Control file and spfile usually are saved into an indivial backup set, spliting from regalur data file. 
     |      Becase data file block format is defined by Oracle, but control file and spfile storage block is same with operating system. They can not mix together.
     |  
     |__ o. The physical output of a backup set is commonly known as "backup piece", which is a physical binary file in an RMAN-specific format.
     |      All the data blocks are being stored in these physical pieces.	 
     |      When you restore the database, the data blocks are being read from backup pieces.
     |
     |__ o. Usally, one backup set is mapping one backup piece. 
     |      But, in some cases, OS file size has maxium limition. So, one backup set will include multiple backup pieces.
     |
     |__ o. The purpose of Oracle introducing Backup set concept is imaging one big database with thousand of data files.
            If each data file backup separately, there will be same amount of backup files generated, which would be hard to manage.
            In RMAN backup configuration, you can specify how many or size limitation of each piece. 			


				 
<5> Example - One backup set maps one backup piece:
     |
     |__ o. RMAN> backup list;
     |
     |__ o. The combination from set 9051 ~ 9057 is called one RMAN database backup.

                 BS Key  Type LV Size       Device Type Elapsed Time Completion Time                                     =====
                 ------- ---- -- ---------- ----------- ------------ --------------------                                    |
                 9501    Incr 0  49.85G     DISK        00:25:17     16-JUL-2017 09:25:25                                    |
                         BP Key: 9501   Status: AVAILABLE  Compressed: NO  Tag: TAG20170716T090007                           | ===> Backup set 9501:
                         Piece Name: /u03/backup/lev_0_emeralit_t949482008_s9513_p1                                          |      1) Contains data block of 7 data files.
                   List of Datafiles in backup set 9501                                                                      |      2) Belongs to level 0 backup. 
                   File LV Type Ckp SCN    Ckp Time             Name                                                         |      3) The mapping physical back piece file is:
                   ---- -- ---- ---------- -------------------- ----                                                         |         "/u03/backup/lev_0_emeralit_t949482008_s9513_p1"
                   3    0  Incr 54534487793 16-JUL-2017 09:00:08 /u02/oradata/nebfprd/undotbs01.dbf                          |  
                   6    0  Incr 54534487793 16-JUL-2017 09:00:08 /u03/oradata/rdms/nebfprd_data00.dbf                        |
                   7    0  Incr 54534487793 16-JUL-2017 09:00:08 /u02/oradata/dms/nebf_data00.dbf                            |
                   10   0  Incr 54534487793 16-JUL-2017 09:00:08 /u01/oradata/nebfprd/users02.dbf                            |
                   11   0  Incr 54534487793 16-JUL-2017 09:00:08 /u01/oradata/nebfprd/system02.dbf                           |
                   12   0  Incr 54534487793 16-JUL-2017 09:00:08 /u01/oradata/nebfprd/TSD_PERFSTAT03.dbf                     |
                   13   0  Incr 54534487793 16-JUL-2017 09:00:08 /u01/oradata/nebfprd/nebf_data01.dbf                    =====
                 
                 BS Key  Type LV Size       Device Type Elapsed Time Completion Time                                     =====
                 ------- ---- -- ---------- ----------- ------------ --------------------                                    |
                 9502    Incr 0  21.71G     DISK        00:13:21     16-JUL-2017 09:38:55                                    |
                         BP Key: 9502   Status: AVAILABLE  Compressed: NO  Tag: TAG20170716T090007                           |
                         Piece Name: /u03/backup/lev_0_emeralit_t949483534_s9514_p1                                          | ===> Backup set 9502
                   List of Datafiles in backup set 9502                                                                      |
                   File LV Type Ckp SCN    Ckp Time             Name                                                         |
                   ---- -- ---- ---------- -------------------- ----                                                         |
                   2    0  Incr 54534488512 16-JUL-2017 09:25:34 /u02/oradata/nebfprd/sysaux01.dbf                           |
                   4    0  Incr 54534488512 16-JUL-2017 09:25:34 /u02/oradata/nebfprd/users01.dbf                            |
                   14   0  Incr 54534488512 16-JUL-2017 09:25:34 /u03/oradata/rdms/ADTRACK_DATA01.DBF                    =====
                 
                 BS Key  Type LV Size       Device Type Elapsed Time Completion Time                                     =====
                 ------- ---- -- ---------- ----------- ------------ --------------------                                    |
                 9503    Incr 0  7.89G      DISK        00:03:59     16-JUL-2017 09:42:59                                    |
                         BP Key: 9503   Status: AVAILABLE  Compressed: NO  Tag: TAG20170716T090007                           |
                         Piece Name: /u03/backup/lev_0_emeralit_t949484340_s9515_p1                                          | ===> Backup set 9503
                   List of Datafiles in backup set 9503                                                                      |
                   File LV Type Ckp SCN    Ckp Time             Name                                                         |
                   ---- -- ---- ---------- -------------------- ----                                                         |
                   9    0  Incr 54534488834 16-JUL-2017 09:39:00 /u02/oradata/nebfprd/TSD_PERFSTAT02.dbf                 =====
                 
                 BS Key  Type LV Size       Device Type Elapsed Time Completion Time                                     =====
                 ------- ---- -- ---------- ----------- ------------ --------------------                                    |
                 9504    Incr 0  1.91G      DISK        00:01:45     16-JUL-2017 09:44:52                                    |
                         BP Key: 9504   Status: AVAILABLE  Compressed: NO  Tag: TAG20170716T090007                           |
                         Piece Name: /u03/backup/lev_0_emeralit_t949484587_s9516_p1                                          |
                   List of Datafiles in backup set 9504                                                                      | ===> Backup set 9504
                   File LV Type Ckp SCN    Ckp Time             Name                                                         |
                   ---- -- ---- ---------- -------------------- ----                                                         |
                   1    0  Incr 54534488933 16-JUL-2017 09:43:07 /u02/oradata/nebfprd/system01.dbf                           |
                   5    0  Incr 54534488933 16-JUL-2017 09:43:07 /u02/oradata/nebfprd/example01.dbf                          |
                   8    0  Incr 54534488933 16-JUL-2017 09:43:07 /u02/oradata/nebfprd/TSD_PERFSTAT.dbf                       |
                   15   0  Incr 54534488933 16-JUL-2017 09:43:07 /u02/oradata/dms/ADTRACK_INDX01.DBF                     =====
                 
                 BS Key  Type LV Size       Device Type Elapsed Time Completion Time                                     =====
                 ------- ---- -- ---------- ----------- ------------ --------------------                                    |
                 9505    Full    15.23M     DISK        00:00:01     16-JUL-2017 09:45:03                                    | ===> Backup set 9505:
                         BP Key: 9505   Status: AVAILABLE  Compressed: NO  Tag: TAG20170716T094502                           |      1) Control file is within this set splitly. 
                         Piece Name: /u03/backup/c-2214550130-20170716-00.ctl                                                |
                   Control File Included: Ckp SCN: 54534488982   Ckp time: 16-JUL-2017 09:45:02                          =====
                 
                 BS Key  Size       Device Type Elapsed Time Completion Time                                             =====
                 ------- ---------- ----------- ------------ --------------------                                            |
                 9506    44.11M     DISK        00:00:02     16-JUL-2017 09:45:13                                            | 
                         BP Key: 9506   Status: AVAILABLE  Compressed: NO  Tag: TAG20170716T094511                           |      
                         Piece Name: /u03/emeralit/backupset/o1_mf_annnn_TAG20170716T094511_dppvh7n1_.bkp                    |
                                                                                                                             | ===> Backup set 9506:
                   List of Archived Logs in backup set 9506                                                                  |      1) Archive log is within this set splitly.
                   Thrd Seq     Low SCN    Low Time             Next SCN   Next Time                                         |
                   ---- ------- ---------- -------------------- ---------- ---------                                         |
                   1    49966   54534437102 16-JUL-2017 05:30:02 54534483495 16-JUL-2017 07:00:05                            |
                   1    49967   54534483495 16-JUL-2017 07:00:05 54534487778 16-JUL-2017 09:00:07                            |
                   1    49968   54534487778 16-JUL-2017 09:00:07 54534489074 16-JUL-2017 09:45:11                        =====
                 
                 BS Key  Type LV Size       Device Type Elapsed Time Completion Time                                     =====
                 ------- ---- -- ---------- ----------- ------------ --------------------                                    |
                 9507    Full    15.23M     DISK        00:00:00     16-JUL-2017 09:45:14                                    | ===> Backup set 9507:
                         BP Key: 9507   Status: AVAILABLE  Compressed: NO  Tag: TAG20170716T094514                           |      1) Control file is within this set splitly.
                         Piece Name: /u03/backup/c-2214550130-20170716-01.ctl                                                |
                   Control File Included: Ckp SCN: 54534489083   Ckp time: 16-JUL-2017 09:45:14                          =====
	 
	 
		
		
<6> Example - One backup set contains multiple backup piece:
     |
     |__ o. Sometimes, the OS platform has limitation of indivial file size, so one backup set has to be divided into several pieces by option "MAXPIECESIZE".
     |
     |__ o. RMAN> run {
                         allocate channel c1 device type disk MAXPIECESIZE 2G format 'C:\app\oracle\fast_recovery_area\EMERALIT\BACKUP\LOCATION_1\test\lev_0_%d_t%t_s%s_p%p';
                         backup database;
                    }	 
				 
				 
				 
         BS Key  Type LV Size       Device Type Elapsed Time Completion Time                                                                =====
         ------- ---- -- ---------- ----------- ------------ ---------------                                                                    |
         12      Full    20.93G     DISK        00:35:03     23-JUL-17                                                                          |
           List of Datafiles in backup set 12                                                                                                   |
           File LV Type Ckp SCN    Ckp Time  Name                                                                                               |
           ---- -- ---- ---------- --------- ----                                                                                               |
           1       Full 2581566    23-JUL-17 C:\APP\ORACLE\ORADATA\EMERALIT\DATAFILE\O1_MF_SYSTEM_DDN2SWN0_.DBF                                 | ===> Backup set #12:
           3       Full 2581566    23-JUL-17 C:\APP\ORACLE\ORADATA\EMERALIT\DATAFILE\O1_MF_SYSAUX_DDN2R52X_.DBF                                 |      1) Including 5 data files.
           5       Full 2581566    23-JUL-17 C:\APP\ORACLE\ORADATA\EMERALIT\DATAFILE\O1_MF_UNDOTBS1_DDN2W03F_.DBF                               |      2) Total set size 20.93 GB.
           6       Full 2581566    23-JUL-17 C:\APP\ORACLE\ORADATA\EMERALIT\DATAFILE\O1_MF_USERS_DDN2VY9O_.DBF                                  |      3) MAXPIECESIZE 2 GB.
           7       Full 2581566    23-JUL-17 C:\APP\ORACLE\ORADATA\EMERALIT\DATAFILE\EMERALIT.DBF                                               |      4) So, 11 pieces included each set.
                                                                                                                                                |      5) Backup set -- Logical Structure.
           Backup Set Copy #1 of backup set 12                                                                                                  |      6) Backup piece -- Physical file.
           Device Type Elapsed Time Completion Time Compressed Tag                                                                              |
           ----------- ------------ --------------- ---------- ---                                                                              |
           DISK        00:35:03     23-JUL-17       NO         TAG20170723T152819                                                               |
                                                                                                                                                |
             List of Backup Pieces for backup set 12 Copy #1                                                                                    |
             BP Key  Pc# Status      Piece Name                                                                                                 |
             ------- --- ----------- ----------                                                                                                 |
             14      1   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P1          |
             15      2   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P2          |
             16      3   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P3          |
             17      4   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P4          |
             18      5   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P5          |
             19      6   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P6          |
             20      7   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P7          |
             21      8   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P8          |
             22      9   AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P9          |
             23      10  AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P10         |
             24      11  AVAILABLE   C:\APP\ORACLE\FAST_RECOVERY_AREA\EMERALIT\BACKUP\LOCATION_1\TEST\LEV_0_EMERALIT_T950110099_S13_P11     =====
         
         BS Key  Type LV Size       Device Type Elapsed Time Completion Time                                                                =====
         ------- ---- -- ---------- ----------- ------------ ---------------                                                                    |
         13      Full    9.64M      DISK        00:00:02     23-JUL-17                                                                          |
                 BP Key: 25   Status: AVAILABLE  Compressed: NO  Tag: TAG20170723T160327                                                        | ===> Backup set #13
                 Piece Name: C:\APP\ORACLE\ADMIN\EMERALIT\DPDUMP\RMAN_CTL\C-3226941073-20170723-01.CTL                                          |      1) Control file backup. 
           SPFILE Included: Modification time: 23-JUL-17                                                                                        |
           SPFILE db_unique_name: EMERALIT                                                                                                      |
           Control File Included: Ckp SCN: 2582883      Ckp time: 23-JUL-17                                                                 =====