Clients operating Oracle databases on Amazon Elastic Compute Cloud (Amazon EC2) usually take database and schema backups utilizing Oracle native instruments like Knowledge Pump and Restoration Supervisor (RMAN) to fulfill information safety, catastrophe restoration (DR), and compliance necessities. A precedence is to scale back backup time as the information grows exponentially and get well sooner in case of failure/catastrophe.
In Half 1 of this two-part collection, we clarify how we will use AWS Backup and Amazon Easy Storage Service (Amazon S3) bucket to carry out the backup and restore of an Oracle Database on AWS EC2.
In Half 2, we offer a mechanism to make use of AWS Backup to create a full backup of the EC2 occasion, together with the OS picture, Oracle binaries, logs, and information recordsdata. The mechanism additionally makes use of Oracle RMAN to carry out archived redo log backup to Amazon Elastic File System (Amazon EFS). Then, we reveal the steps to revive a database to a particular point-in-time utilizing AWS Backup and Oracle RMAN.
Answer overview
Determine 1 demonstrates the workflow:
- Oracle database on Amazon EC2 configured with Oracle Safe Backup.
- AWS Backup service to backup EC2 occasion at common intervals.
- Amazon EFS for storing Oracle RMAN archive log backups.

Determine 1. Oracle Database in Amazon EC2 utilizing AWS Backup and EFS for backup and restore
Stipulations
- An AWS account
- Oracle database and AWS CLI in an EC2 occasion
- Entry to configure AWS Backup
- Entry to configure EFS to retailer the Oracle RMAN archive log backups
1. Configure AWS Backup
Configure AWS Backup as detailed in Step 1 of Half 1.
Oracle RMAN archive log backup
Whereas AWS Backup is now making a day by day backup of the EC2 occasion, we additionally wish to be sure that we backup the archived log recordsdata to a protected location. This can allow us to do point-in-time restores and restore to more moderen instances than simply the final day by day EC2 backup. Under we offer the steps to backup archive log utilizing RMAN to Amazon EFS.
Backup/restore archive logs to/from Amazon EFS
Backing up the Oracle Archive logs is a crucial a part of the method. On this part, we’ll describe how one can backup their Oracle archive logs to Amazon EFS. One benefit of this selection (as in contrast with utilizing Oracle Safe Backup [detailed in Part 1 of this series]) is that it doesn’t require any further Oracle licensing.
2. Configure Amazon EFS
a. Create an Amazon EFS file system that will likely be used to retailer Oracle RMAN Archive log backups. The picture under particulars the steps concerned in creation of an Amazon EFS. Contemplate {that a} pattern file system ID: fs-0123abcdef012345
is created and will likely be used to retailer RMAN archive log backup.

Determine 2. Configure Amazon EFS which is used to retailer Oracle RMAN archive log backups
b. Set up the Amazon EFS Consumer and comply with directions to put in EFS consumer on RHEL EC2 occasion. Observe: subsequent steps had been examined on RHEL 7.9.
sudo yum -y set up git
sudo yum -y set up rpm-build
git clone https://github.com/aws/efs-utils
cd efs-utils/
sudo yum -y set up make
sudo make rpm
sudo yum -y set up ./construct/amazon-efs-utils*rpm
c. Mount the EFS file system in your EC2 occasion. On this instance, we present the steps to mount EFS filesystem on EC2 Occasion (if the command requests to improve stunnel, seek advice from Upgrading stunnel. Be certain that the EC2 occasion profile connected has vital insurance policies to entry EFS. /rman
for mount level and file system ID: fs-0123abcdef012345
are examples for EFS file system.
sudo mkdir /rman
sudo mount -t efs -o tls,iam fs-0123abcdef012345 /rman
d. To mount EFS file system routinely on EC2 occasion reboot, add an entry in /and many others/fstab
. This instance is for RHEL EC2 occasion:
fs-0123abcdef012345:/ /rman efs _netdev,tls,iam 0 0
3. Configure RMAN backup to Amazon EFS
With Amazon EFS mounted on EC2 occasion, we will configure Oracle RMAN archive log backups to EFS. In under instructions oratst
is used for instance of your ORACLE_SID
.
a. Configure RMAN repository to take management file backup to Amazon EFS routinely.
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/rman/ctrl-D_percentd_percentF';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
b. Create a script (for instance, rman_archive.sh) with under instructions and schedule utilizing crontab (instance entry: */5 * * * * rman_archive.sh
) to run each 5 minutes. This can make sure that Oracle Archive logs are backed as much as Amazon EFS (/rman
) incessantly, making certain an restoration level goal (RPO) of 5 minutes.
dt=`date +%Ypercentmpercentd_percentHpercentMpercentS`
rman goal / log=/rman/rman_arch_bkup_oratst_${dt}.log <<EOF
RUN
{
allocate channel c1_efs system sort disk format '/rman/arch-D-%d_percentT_spercents_ppercentp' MAXPIECESIZE 10G;
BACKUP ARCHIVELOG ALL delete all enter;
launch channel c1_efs;
}
EOF
4. Carry out database point-in-time restoration
In occasion of a database crash/corruption, we will use AWS Backup service and Oracle RMAN archive log backup to get well database to a particular point-in-time.
a. Usually, you’d choose the newest Restoration Level accomplished earlier than the time to which you want to get well. Utilizing AWS Backup, determine the Restoration level ID to revive by following the steps from Restoring an Amazon EC2 occasion. Observe: when following the steps, make sure to set the “Person information” settings as described within the subsequent bulleted merchandise.
After the EBS volumes are created from the snapshot, there is no such thing as a want to attend for all the information to switch from Amazon S3 to your Amazon EBS quantity earlier than your connected occasion can begin accessing the amount. Amazon EBS Snapshots implement lazy loading, so as to start utilizing them straight away.
b. Be certain that database doesn’t begin routinely after restoring the EC2 occasion, by renaming /and many others/oratab
. Use under command in “Person information” part whereas restoring EC2 occasion. After database restoration, we will rename it again to /and many others/oratab
.
#!/usr/bin/sh
sudo su -
mv /and many others/oratab /and many others/oratab_bk
c. Login to the EC2 occasion as soon as it’s up and execute the RMAN restoration instructions talked about under. Establish the DBID
from RMAN logs saved within the EFS. Under instructions use database oratst
for instance.
rman goal /
RMAN> startup nomount
RMAN> set dbid DBID
# Under command is to revive the controlfile from autobackup
RMAN> RUN
{
set controlfile autobackup format for system sort disk to '/rman/ctrl-D_percentd_percentF';
RESTORE CONTROLFILE FROM AUTOBACKUP;
alter database mount;
}
#Establish the restoration level (sequence_number) by itemizing the backups accessible in catalog.
RMAN> checklist backup;
In Determine 3, the newest archive log backed up is 460, so you need to use this sequence quantity within the subsequent set of RMAN instructions.
RMAN> RUN
{
allocate channel c1_efs system sort disk format '/rman/arch-D-%d_percentT_spercents_ppercentp';
get well database till sequence sequence_number;
ALTER DATABASE OPEN RESETLOGS;
launch channel c1_efs;
}
Determine 3. Pattern output of Oracle RMAN “checklist backup” command
d. To keep away from efficiency points as a result of lazy loading, after the database is open, you’ll be able to run under command to drive a quicker restoration of the blocks from S3 bucket to EBS volumes (under instance allocates two channels and validates your entire database).
RMAN> RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
ALLOCATE CHANNEL c2 DEVICE TYPE DISK;
VALIDATE database part dimension 1200M;
}
e. This completes the restoration of database, and we will let the database to auto begin by renaming file again to /and many others/oratab
.
mv /and many others/oratab_bk /and many others/oratab
5. Backup retention
Be certain that the AWS Backup Lifecycle coverage match Oracle archive log backup retention. Additionally, comply with documentation to configure Oracle backup retention and deleting expired backup. Under is a pattern command for Oracle backup retention.
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS;
RMAN> RUN
{
allocate channel c1_efs system sort disk format '/rman/arch-D-%d_percentT_spercents_ppercentp';
crosscheck backup;
delete noprompt out of date;
delete noprompt expired backup;
launch channel c1_efs;
}
Cleanup
Observe under directions to take away or cleanup the setup:
- Delete the backup plan created in Step 1.
- Take away the cron entry from the EC2 occasion configured in Step 3b.
- Delete the EFS that was created in Step 2 to retailer Oracle RMAN archive log backups.
Conclusion
On this put up, we demonstrated the use for AWS Backup for EC2 snapshot and EFS as storage for Oracle RMAN archive log backups. With this technique for backup, Oracle Database operating on EC2 might be restored and recovered to a point-in-time quicker than oracle native backup and restoration methods. Additionally, through the use of EFS for Oracle RMAN archive log backups, we will keep away from the extra licensing required to make use of Oracle Safe Backup, defined in Half 1. You’ll be able to leverage this answer to facilitate restoring copies of your manufacturing database for growth or testing functions and to Get well from a person error that removes information or corrupts current information.
To study extra about AWS Backup, seek advice from the AWS Backup Documentation.