Oracle Recovery Manager (RMAN) and Amazon RDS Snapshots - Oracle to Aurora PostgreSQL Migration Playbook

Oracle Recovery Manager (RMAN) and Amazon RDS Snapshots

Feature compatibility AWS SCT / AWS DMS automation level AWS SCT action code index Key differences

Four star feature compatibility

N/A

N/A

Storage level backup managed by Amazon RDS.

Oracle Usage

Oracle Recovery Manager (RMAN) is a primary backup and recovery tool in Oracle. It provides its own scripting syntax and can be used to take full or incremental backups of an Oracle database. The following list identifies the types of backups.

  • Full RMAN Backup — Take a full backup of an entire database or individual Oracle data files. For example, a level 0 full backup.

  • Differential Incremental RMAN Backup — Performs a backup of all database blocks that have changed from the previous level 0 or 1 backup.

  • Cumulative Incremental RMAN Backup — Perform a backup all of blocks that have changed from the previous level 0 backup.

RMAN supports online backups of an Oracle database if it has been configured to run in Archived Log Mode.

RMAN backs up the following files:

  • Database data files.

  • Database control file.

  • Database parameter file.

  • Database Archived Redo Logs.

Examples

Use the RMAN CLI to connect to an Oracle database.

export ORACLE_SID=ORCL
rman target=/

Perform a full backup of the database and the database archived redo logs.

BACKUP DATABASE PLUS ARCHIVELOG;

Perform an incremental level 0 or level 1 backup of the database.

BACKUP INCREMENTAL LEVEL 0 DATABASE;
BACKUP INCREMENTAL LEVEL 1 DATABASE;

Restore a database.

RUN {
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN;
}

Restore a specific pluggable database (Oracle 12c).

RUN {
ALTER PLUGGABLE DATABASE pdbA, pdbB CLOSE;
RESTORE PLUGGABLE DATABASE pdbA, pdbB;
RECOVER PLUGGABLE DATABASE pdbA, pdbB;
ALTER PLUGGABLE DATABASE pdbA, pdbB OPEN;
}

Restore a database to a specific point in time.

RUN {
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
SET UNTIL TIME "TO_DATE('20-SEP-2017 21:30:00','DD-MON-YYYY HH24:MI:SS')";
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;
}

List all current database backups created with RMAN.

LIST BACKUP OF DATABASE;

For more information, see Backup and Recovery User Guide in the Oracle documentation.

PostgreSQL Usage

Snapshots are the primary backup mechanism for Amazon Aurora databases. They are extremely fast and nonintrusive. You can take snapshots using the Amazon RDS Management Console or the AWS CLI. Unlike RMAN, there is no need for incremental backups. You can choose to restore your database to the exact time when a snapshot was taken or to any other point in time. Amazon Aurora provides the following types of backups:

  • Automated Backups — Always enabled on Amazon Aurora. They do not impact database performance.

  • Manual Backups — You can create a snapshot at any time. There is no performance impact when taking snapshots of an Aurora database. Restoring data from snapshots requires creation of a new instance. Up to 100 manual snapshots are supported for each database.

Examples

For examples, see PostgreSQL Amazon Aurora Snapshots.

Summary

Description Oracle Amazon Aurora

Scheduled backups

Create DBMS_SCHEDULER job that will run your RMAN script on a scheduled basis.

Automatic

Manual full database backups

BACKUP DATABASE PLUS ARCHIVELOG;

Use Amazon RDS dashboard or the AWS CLI command to take a snapshot on the cluster.

aws rds create-db-cluster-snapshot
  --dbcluster-snapshot-identifier Snapshot_name
  --db-cluster-identifier Cluster_Name

Restore database

RUN
{
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN;
}

Create new cluster from a cluster snapshot.

aws rds restore-db-cluster-from-snapshot
  --db-cluster-identifier NewCluster
  --snapshotidentifier SnapshotToRestore
  --engine aurora-postgresql

Add a new instance to the new/restored cluster.

aws rds create-db-instance
  --region useast-1
  --db-subnet-group default
  --engine aurora-postgresql
  --db-cluster-identifier clustername-restore
  --db-instance-identifier newinstance-nodeA
  --db-instance-class db.r4.large

Incremental differential

BACKUP INCREMENTAL LEVEL 0
DATABASE;
BACKUP INCREMENTAL LEVEL 1
DATABASE;

N/A

Incremental cumulative

BACKUP INCREMENTAL LEVEL 0
CUMULATIVE DATABASE;
BACKUP INCREMENTAL LEVEL 1
CUMULATIVE DATABASE;

N/A

Restore database to a specific point in time

RUN {
  SHUTDOWN IMMEDIATE;
  STARTUP MOUNT;
  SET UNTIL TIME "TO_DATE(
    '19-SEP-2017 23:45:00',
    'DD-MON-YYYY HH24:MI:SS')";
  RESTORE DATABASE;
  RECOVER DATABASE;
  ALTER DATABASE
  OPEN RESETLOGS;
}

Create a new cluster from a cluster snapshot by given custom time to restore.

aws rds restore-db-cluster-to-point-in-time
  --db-cluster-identifier clustername-restore
  --source-db-cluster-identifier clustername
  --restore-to-time 2017-09-19T23:45:00.000Z

Add a new instance to the new or restored cluster.

aws rds create-db-instance
  --region useast-1
  --db-subnet-group default
  --engine aurora-postgresql
  --db-cluster-identifier clustername-restore
  --db-instance-identifier newinstance-nodeA
  --db-instance-class db.r4.large

Backup database archive logs

BACKUP ARCHIVELOG ALL;

N/A

Delete old database archive logs

CROSSCHECK BACKUP;
DELETE EXPIRED BACKUP;

N/A

Restore a single pluggable database (12c)

RUN {
  ALTER PLUGGABLE DATABASE pdb1, pdb2 CLOSE;
  RESTORE PLUGGABLE DATABASE pdb1, pdb2;
  RECOVER PLUGGABLE DATABASE pdb1, pdb2;
  ALTER PLUGGABLE DATABASE pdb1, pdb2
  OPEN;
}

Create new cluster from a cluster snapshot.

aws rds restore-db-cluster-from-snapshot
  --db-cluster-identifier NewCluster
  --snapshotidentifier SnapshotToRestore
  --engine aurora-postgresql

Add a new instance to the new or restored cluster.

aws rds create-db-instance
  --region useast-1
  --db-subnet-group default
  --engine aurora-postgresql
  --db-cluster-identifier clustername-restore
  --db-instance-identifier newinstance-nodeA
  --db-instance-class db.r4.large

Use pg_dump and pg_restore to copy the database to the original instance.

pgdump -F c
  -h hostname.rds.amazonaws.com
  -U username
  -d hr -p 5432 > c:\Export\hr.dmp

pg_restore
  -h restoredhostname.rds.amazonaws.com
  -U hr -d hr_restore
  -p 5432 c:\Export\hr.dmp

Optionally, replace with the old database using ALTER DATABASE RENAME.

For more information, see rds in the CLI Command Reference and Restoring a DB instance to a specified time and Restoring from a DB snapshot in the Amazon RDS user guide.