I want to use Recovery Manager (RMAN) to take a backup of my Amazon Relational Database Service (Amazon RDS) for Oracle DB instance.
Resolution
Before you take an RMAN backup of your Amazon RDS for Oracle DB instance, note the following limitations:
- When you perform an RMAN backup in your DB instance, you consume space from the allocated storage for that instance. You can also use Amazon Elastic File System (Amazon EFS) integration to store backup files in extended storage without increasing the overall storage size of your DB instance.
- Features like the parallel option for backups, backup compression, database validation, and block change tracking are available to only Oracle Enterprise Edition users. For more information, see Oracle Database Editions on the Oracle website.
- RMAN features aren't supported for RDS for Oracle read replicas but you can use block change tracking on read replicas.
- You must activate automated backups for your DB instances before you perform an RMAN backup. Because RMAN backups are online operations, the archive log must be turned on. When you activate automated backup on your instance, you also set the DB instance in Archive Log Mode.
Perform RMAN backup of your DB instance
Use one of the following methods to perform the RMAN backup of your DB instance:
To monitor the amount of storage consumed by the directory, run the following query:
SELECT round(SUM(filesize)/1024/1024/1024, 3) SIZE_IN_GB FROM TABLE(rdsadmin.rds_file_util.listdir('<DIRECTORY_NAME>'));
Perform a full database backup of your DB instance
When you perform a full database backup, you back up all the data files in your DB instance. This includes the control files and the stored procedures file.
To perform a full database backup with the tag name Full_DB_BACKUP in the DATA_PUMP_DIR with default task parameters, run the following query:
BEGIN
rdsadmin.rdsadmin_rman_util.backup_database_full(
p_owner => 'SYS',
p_directory_name => 'DATA_PUMP_DIR',
p_tag => 'FULL_DB_BACKUP',
p_rman_to_dbms_output => FALSE);
END;
/
Perform an incremental database backup of your DB instance
Incremental backups use an additional parameter called p_level. To perform a full incremental backup, set p_level to 0. To perform an incremental differential backup, set p_level to 1. For more information, see About RMAN incremental backups on the Oracle website.
Like full backups, incremental backups for RDS for Oracle DB instances have common parameters that you can set before you start the backup.
To perform an incremental backup with the tag name MY_INCREMENTAL_BACKUP in the DATA_PUMP_DIR directory with default task parameters, run the following procedure:
BEGIN
rdsadmin.rdsadmin_rman_util.backup_database_incremental(
p_owner => 'SYS',
p_directory_name => 'DATA_PUMP_DIR',
p_level => 1,
p_tag => 'MY_INCREMENTAL_BACKUP',
p_rman_to_dbms_output => FALSE);
END;
/
Perform an archive log backup of your DB instance
Use the Amazon RDS for Oracle rdsadmin_rman_util package to back up your archive logs based on SCN range, sequence number range and date range.
Run the following procedure to back up archive logs for your instance in the ARCHIVE_LOG_BACKUP directory with the tag name LOG_BACKUP. To modify the settings for your archive log backups, see Performing common RMAN tasks for Oracle DB instances.
--creating a directory to store archive log backups
EXEC rdsadmin.rdsadmin_util.create_directory(p_directory_name => 'ARCHIVE_LOG_BACKUP');
--performing archive log backup
BEGIN
rdsadmin.rdsadmin_rman_util.backup_archivelog_all(
p_owner => 'SYS',
p_directory_name => 'ARCHIVE_LOG_BACKUP',
p_tag => 'LOG_BACKUP',
p_rman_to_dbms_output => FALSE);
END;
/
Perform a tablespace backup of your DB instance
Use the common parameters described in Backing up a tablespace to perform an individual tablespace backup of your DB instance. The following example command backs up the USERS1 tablespace in the custom directory TB_BACKUP with the tag name MYTABLESPACE_BACKUP.
BEGIN
rdsadmin.rdsadmin_rman_util.backup_tablespace(
p_owner => 'SYS',
p_directory_name => 'TB_BACKUP',
p_tablespace_name => 'USERS1',
p_tag => 'MYTABLESPACE_BACKUP',
p_rman_to_dbms_output => FALSE);
END;
/
Note: You can also use the rdsadmin_rman_util procedure to perform the backup of the control file. For more information, see Backing up a control file.
Monitor RMAN backup jobs
To monitor the RMAN backup, use SQL queries or check the log files that are generated for the RMAN task.
Use the following methods to access the log files for RMAN backup jobs:
-
Set p_rman_to_dbms_output to TRUE for the RMAN task that you want to run. Be sure to set serveroutput to on before you run the rdsadmin_rman_util package.
-
To list the RMAN task log files, review the logs and events section on the Amazon RDS console.
-
If the RMAN backup task is complete, then you can also run the following SQL query to list the RMAN task logs. Then, use the rdsadmin.rds_file_util.read_text_file procedure to read the logs. For more information, see Listing files.
column filename format a70
set linesize 200
SELECT * FROM TABLE(rdsadmin.rds_file_util.listdir('BDUMP')) where filename like '%rman%';
-
To check the directory size where the RMAN backup is stored, first run the following query. Then, monitor the storage consumption.
SELECT round(SUM(filesize)/1024/1024, 3) SIZE_IN_MB FROM TABLE(rdsadmin.rds_file_util.listdir('<DIRECTORY_NAME>'));
-
To list the status of the backup job with the amount of time taken to complete the RMAN backup job, run the following query.
set linesize 500 pagesize 2000
col Hours format 9999.99
col STATUS format a10
select SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'mm-dd-yyyy hh24:mi:ss') as RMAN_Bkup_start_time,
to_char(END_TIME,'mm-dd-yyyy hh24:mi:ss') as RMAN_Bkup_end_time,
elapsed_seconds/3600 Hours from V$RMAN_BACKUP_JOB_DETAILS
order by session_key;
Related information
Performing miscellaneous tasks for Oracle DB instances
Performing common log-related tasks for Oracle DB instances
Amazon RDS for Oracle database log files