How to Backup Files with Oracle 12c’s Recovery Management Backup Sets - dummies

How to Backup Files with Oracle 12c’s Recovery Management Backup Sets

By Chris Ruel, Michael Wessler

Oracle 12c’s Recovery Management (RMAN) makes backing up your database a breeze. The examples in this section are hot backups to the Fast Recovery Area.

A hot backup is simply a backup while the database is running. You can do it at any time, but you should usually pick a time when there is less activity. That way, the hot backup won’t compete for resources.

  1. Launch RMAN.

    These examples don’t use a recovery catalog. Just remember to connect to it if you choose to use one.

  2. Set your database to automatically back up the control file and spfile:

  3. If you see something like this, skip to Step 5:

    RMAN configuration parameters for database with db_unique_name DEV12C are:

    If your response reads as follows, go to Step 4.

  4. Type the following:


    You should see this:

    new RMAN configuration parameters:
    new RMAN configuration parameters are successfully stored
  5. Get a list of the data files in your database:


<report schema;>        

How to back up the database or tablespaces in Oracle 12c

You can back up the database and tablespaces in several ways:

  • Back up the whole database.

  • Back up one or more tablespaces.

  • Back up one or more data files.

To back up the whole database, type the following:

<backup database;>

The output should look something like this:

Starting backup at 30-JUN-2013 10:45:10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=48 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/dev12c/sysaux01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/dev12c/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/dev12c/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/dev12c/rman_data01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/dev12c/users01.dbf
channel ORA_DISK_1: starting piece 1 at 30-JUN-2013 10:45:12
channel ORA_DISK_1: finished piece 1 at 30-JUN-2013 10:48:18
piece handle=/u01/app/oracle/fast_recovery_area/DEV12C/backupset/2013_06_30/o1_mf_nnndf_TAG20130630T104511_8x0k3rlq_.bkp tag=TAG20130630T104511 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:06
Finished backup at 30-JUN-2013 10:48:18
Starting Control File and SPFILE Autobackup at 30-JUN-2013 10:48:18
piece handle=/u01/app/oracle/fast_recovery_area/DEV12C/autobackup/2013_06_30/ o1_mf_s_819456498_8x0k9lql_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 30-JUN-2013 10:48:19

To back up just one tablespace, type the following:

<backup tablespace users;>

To back up two tablespaces at the same time, type the following:

<backup tablespace system, users;>

How to name your backups in Oracle 12c

You can give your backup a name. It’s called a tag. A tag can be an alphanumeric string up to 30 characters.

Type the following to back up your database and give it a name (database_full_backup in this case):

<backup database tag=database_full_backup;>

How to compress your backups in Oracle 12c

As of Oracle 10g, you can compress your backups as they run. Compression usually shows a significant reduction in space usage.

Take a compressed backup of your entire database with this code:

<backup as compressed backupset database tag=compressed_full_bak;>

How to perform incremental backups in Oracle 12c

You may want to consider an incremental backup, which copies only some of the blocks based on when the last incremental was done and what blocks have changed. Incremental backups come in three levels (0 and 1 differential and 1 cumulative) published in Oracle 12c:

  • Differential copies only blocks that have changed since the last incremental backup of any type.

  • Cumulative gets all blocks that were changed since the last level-0 backup, even if several level-1 differentials were taken since then.

Incremental backups conserve time and space when you’re designing a backup strategy. You might consider an incremental strategy if your database is extremely large.

Because backups incur overhead on the system, if at all possible, don’t run them when users are trying to access data. If your database is getting large and the backup has run for five hours and is cutting into core business hours, look at an incremental approach to your backups and/or increasing backup job parallelism.

These are typical solutions that use incremental backups:

  • You schedule your full weekly backup for Sunday at 3:00 a.m. This backup takes five hours to complete during the least amount of user activity on the system. Your database is 400GB, and even though you compress the backup it still takes 50GB of space.

  • You schedule a differential level-1 backup to run daily at 3:00 a.m., Monday through Saturday. This backup takes only 15 minutes and is 2GB in size after compression.

Block change tracking for Oracle 12c

Block change tracking just tracks what blocks have changed; when it comes time to do an incremental backup, you can get the blocks that you need instead of reading every single one. This technique speeds up incremental backups tremendously.

Check to see whether your database has block change tracking enabled:

<select *
from v$block_change_tracking;>

If it does not, enable block change tracking:

<alter database enable block change tracking
 Using file <specify a file name here>;>

Put the file with the rest of your data files and name it something like block_change_tracking.dbf. This feature has little overhead. The block change tracking file is, on average, 1/30,000 the size of the data blocks to be tracked. You can have a very large database before worrying about this file taking up much space.

To do the weekly level-0 backup on Sunday, type the following:

<backup incremental level 0 as compressed backupset database tag=weekly_level_0;>

To do the daily level-1 backup, type the following:

<backup incremental level 1 as compressed backupset database tag=daily_level_1;>

Do the daily backup every day besides Sunday if you’re doing a weekly level 0 on Sunday. If you’re doing a monthly level 0 (for example, on the first of the month), run the daily level 1 every other day of the month. Basically, if you’re doing a level 0 on a given day, there’s no need to do a level 1.