Clients working 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 knowledge safety, catastrophe restoration (DR), and compliance necessities. A precedence is to cut back backup time as the information grows exponentially and get well sooner in case of failure/catastrophe.
In conditions the place RMAN backup is used as a DR resolution, utilizing AWS Backup to backup the file system and utilizing RMAN to backup the archive logs are an environment friendly technique to carry out Oracle database point-in-time restoration within the occasion of a catastrophe.
Pattern use instances:
- Shortly construct a replica of manufacturing database to check bug fixes or for a tuning train.
- Get well from a person error that removes knowledge or corrupts current knowledge.
- A whole database restoration after a media failure.
There are two choices to backup the archive logs utilizing RMAN:
- Utilizing Oracle Safe Backup (OSB) and an Amazon Easy Storage Service (Amazon S3) bucket because the storage for archive logs
- Utilizing Amazon Elastic File System (Amazon EFS) because the storage for archive logs
That is Half 1 of this two-part collection, 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 knowledge recordsdata. On this publish, we’ll use Oracle RMAN to carry out archived redo log backup to an Amazon S3 bucket. Then, we display the steps to revive a database to a selected point-in-time utilizing AWS Backup and Oracle RMAN.
Resolution overview
Determine 1 demonstrates the workflow:
- Oracle database on Amazon EC2 configured with Oracle Safe Backup (OSB)
- AWS Backup service to backup EC2 occasion at common intervals.
- AWS Identification and Entry Administration (IAM) function for EC2 occasion that grants permission to jot down archive log backups to Amazon S3
- S3 bucket for storing Oracle RMAN archive log backups

Determine 1. Oracle Database in Amazon EC2 utilizing AWS Backup and S3 for backup and restore
Stipulations
For this resolution, the next conditions are required:
- An AWS account
- Oracle database and AWS CLI in an EC2 occasion
- Entry to configure AWS Backup
- Acces to S3 bucket to retailer the RMAN archive log backup
1. Configure AWS Backup
You possibly can select AWS Backup to schedule every day backups of the EC2 occasion. AWS Backup effectively shops your periodic backups utilizing backup plans. Solely the primary EBS snapshot performs a full copy from Amazon Elastic Block Storage (Amazon EBS) to Amazon S3. All subsequent snapshots are incremental snapshots, copying simply the modified blocks from Amazon EBS to Amazon S3, thus, decreasing backup length and storage prices. Oracle helps Storage Snapshot Optimization, which takes third-party snapshots of the database with out inserting the database in backup mode. By default, AWS Backup now creates crash-consistent backups of Amazon EBS volumes which can be connected to an EC2 occasion. Clients not need to cease their occasion or coordinate between a number of Amazon EBS volumes connected to the identical EC2 occasion to make sure crash-consistency of their utility state.
You possibly can create every day scheduled backup of EC2 cases. Figures 2, 3, and 4 are pattern screenshots of the backup plan, associating an EC2 occasion with the backup plan.

Determine 2. Configure backup rule utilizing AWS Backup

Determine 3. Choose EC2 occasion containing Oracle Database for backup

Determine 4. Abstract display screen exhibiting the backup rule and assets managed by AWS Backup
Oracle RMAN archive log backup
Whereas AWS Backup is now making a every day backup of the EC2 occasion, we additionally wish to make sure that we backup the archived log recordsdata to a protected location. This may allow us to do point-in-time restores and restore to different current instances than simply the final every day EC2 backup. Right here, we offer the steps to backup archive log utilizing RMAN to S3 bucket.
Backup/restore archive logs to/from Amazon S3 utilizing OSB
Backing-up the Oracle archive logs is a vital a part of the method. On this part, we’ll describe how one can backup their Oracle Archive logs to Amazon S3 utilizing OSB. Word: OSB is a individually licensed product from Oracle Company, so you will have to be correctly licensed for OSB when you use this strategy.
2. Setup S3 bucket and IAM function
Oracle Archive log backups may be scheduled utilizing cron
script to run at common interval (for instance, each quarter-hour). These backups are saved in an S3 bucket.
a. Create an S3 bucket with lifecycle coverage to transition the objects to S3 Normal-Rare Entry.
b. Connect the next coverage to the IAM Position of EC2 containing Oracle database or create an IAM function (ec2access
) with the next coverage and fix it to the EC2 occasion. Replace bucket-name
with the bucket created in earlier step.
{ "Sid": "S3BucketAccess", "Impact": "Permit", "Motion": [ "s3:PutObject", "s3:GetObjectAcl", "s3:GetObject", "s3:ListBucket", "s3:DeleteObject" ], "Useful resource": [ "arn:aws:s3:::bucket-name", "arn:aws:s3:::bucket-name/*" ] }
3. Setup OSB
After we’ve configured the backup of EC2 occasion utilizing AWS Backup, we setup OSB within the EC2 occasion. In these steps, we present the mechanism to configure OSB.
a. Confirm {hardware} and software program conditions for OSB Cloud Module.
b. Login to the EC2 occasion with Consumer ID proudly owning the Oracle Binaries.
c. Obtain Amazon S3 backup installer file (osbws_install.zip)
d. Create Oracle pockets listing.
mkdir $ORACLE_HOME/dbs/osbws_wallet
e. Create a file (osbws.sh) within the EC2 occasion with the next instructions. Replace IAM function with the one created/up to date in Step 2b.
java -jar osbws_install.jar —IAMRole ec2access walletDir $ORACLE_HOME/dbs/osbws_wallet -libDir $ORACLE_HOME/lib/
f. Change permission and run the file.
chmod 700 osbws.sh
./osbws.sh
Pattern output: AWS credentials are legitimate.
Oracle Safe Backup Net Service pockets created in listing /u01/app/oracle/product/19.3.0.0/db_1/dbs/osbws_wallet.
Oracle Safe Backup Net Service initialization file /u01/app/oracle/product/19.3.0.0/db_1/dbs/osbwsoratst.ora created.
Downloading Oracle Safe Backup Net Service Software program Library from file osbws_linux64.zip.
Obtain full.
g. Set ORACLE_SID by executing under command:
. oraenv
h. Operating the script – osbws.sh installs OSB libraries and creates a file known as osbws<ORACLE_SID>.ora
.
i. Add/modify under with S3 bucket(bucket-name
) and area(ex:us-west-2
) created in Step 2a.
OSB_WS_HOST=http://s3.us-west-2.amazonaws.com
OSB_WS_BUCKET=bucket-name
OSB_WS_LOCATION=us-west-2
4. Configure RMAN backup to S3 bucket
With OSB put in within the EC2 occasion, you possibly can backup Oracle archive logs to S3 bucket. These backups can be utilized to carry out database point-in-time restoration in case of database crash/corruption . oratst
is used for example in under instructions.
a. Configure RMAN repository. Instance under makes use of Oracle 19c and Oracle Sid – oratst
.
RMAN> configure channel machine sort sbt parms="SBT_LIBRARY=/u01/app/oracle/product/19.3.0.0/db_1/lib/libosbws.so,SBT_PARMS=(OSB_WS_PFILE=/u01/app/oracle/product/19.3.0.0/db_1/dbs/osbwsoratst.ora)";
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 may makes positive Oracle Archive logs are backed as much as Amazon S3 regularly, thus guaranteeing an restoration level goal (RPO) of 5 minutes.
dt=`date +%Ypercentmpercentd_percentHpercentMpercentS`
rman goal / log=rman_arch_bkup_oratst_${dt}.log <<EOF
RUN
{
allocate channel c1_s3 machine sort sbt
parms="SBT_LIBRARY=/u01/app/oracle/product/19.3.0.0/db_1/lib/libosbws.so,SBT_PARMS=(OSB_WS_PFILE=/u01/app/oracle/product/19.3.0.0/db_1/dbs/osbwsoratst.ora)" MAXPIECESIZE 10G;
BACKUP ARCHIVELOG ALL delete all enter;
Backup CURRENT CONTROLFILE;
launch channel c1_s3;
}
EOF
c. Copy RMAN logs to S3 bucket. These logs include the database identifier (DBID) that’s required when we’ve to revive the database utilizing Oracle RMAN.
aws s3 cp rman_arch_bkup_oratst_${dt}.log s3://bucket-name
5. Carry out database point-in-time restoration
Within the occasion of a database crash/corruption, we will use AWS Backup service and Oracle RMAN Archive log backup to get well database to a selected point-in-time.
a. Sometimes, you’ll choose the newest restoration level accomplished earlier than the time you want to get well. Utilizing AWS Backup, determine the restoration level ID to revive by following the steps on restoring an Amazon EC2 occasion. Word: when following the steps, make sure to set the “Consumer knowledge” settings as described within the subsequent bullet merchandise.
After the EBS volumes are created from the snapshot, there isn’t a want to attend for all the knowledge to switch from Amazon S3 to your EBS quantity earlier than your connected occasion can begin accessing the amount. Amazon EBS snapshots implement lazy loading, to be able to start utilizing them instantly.
b. Make sure the database doesn’t begin robotically after restoring the EC2 occasion, by renaming /and many others/oratab
. Use the next command in “Consumer knowledge” 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. Determine the DBID
from RMAN logs saved within the S3 bucket. These instructions use database oratst
for example:
rman goal /
RMAN> startup nomount
RMAN> set dbid DBID
# Beneath command is to revive the controlfile from autobackup
RMAN> RUN
{
allocate channel c1_s3 machine sort sbt
parms="SBT_LIBRARY=/u01/app/oracle/product/19.3.0.0/db_1/lib/libosbws.so,SBT_PARMS=(OSB_WS_PFILE=/u01/app/oracle/product/19.3.0.0/db_1/dbs/osbwsoratst.ora)";
RESTORE CONTROLFILE FROM AUTOBACKUP;
alter database mount;
launch channel c1_s3;
}
#Determine the restoration level (sequence_number) by itemizing the backups obtainable in catalog.
RMAN> checklist backup;
In Determine 5, the newest archive log backed up is 380, so you need to use this sequence quantity within the subsequent set of RMAN instructions.

Determine 5. Pattern output of Oracle RMAN “checklist backup” command
RMAN> RUN
{
allocate channel c1_s3 machine sort sbt
parms="SBT_LIBRARY=/u01/app/oracle/product/19.3.0.0/db_1/lib/libosbws.so,SBT_PARMS=(OSB_WS_PFILE=/u01/app/oracle/product/19.3.0.0/db_1/dbs/osbwsoratst.ora)";
get well database till sequence sequence_number;
ALTER DATABASE OPEN RESETLOGS;
launch channel c1_s3;
}
d. To keep away from efficiency points resulting from lazy loading, after the database is open, run the next command to drive a sooner restoration of the blocks from S3 bucket to EBS volumes (this instance allocates two channels and validates the whole database).
RMAN> RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
ALLOCATE CHANNEL c2 DEVICE TYPE DISK;
VALIDATE database part measurement 1200M;
}
e. This completes the restoration of database, and we will let the database robotically begin by renaming file again to /and many others/oratab
.
mv /and many others/oratab_bk /and many others/oratab
6. Backup retention
Make sure that the AWS Backup lifecycle coverage matches the Oracle Archive log backup retention. Additionally, comply with documentation to configure Oracle backup retention and delete expired backups. It 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_s3 machine sort sbt
parms="SBT_LIBRARY=/u01/app/oracle/product/19.3.0.0/db_1/lib/libosbws.so,SBT_PARMS=(OSB_WS_PFILE=/u01/app/oracle/product/19.3.0.0/db_1/dbs/osbwsoratst.ora)";
crosscheck backup;
delete noprompt out of date;
delete noprompt expired backup;
launch channel c1_s3;
}
Cleanup
Observe under directions to take away or cleanup the setup:
- Delete the backup plan created in Step 1.
- Uninstall Oracle Safe Backup from the EC2 occasion.
- Delete/Replace IAM function (
ec2access
) to take away entry from the S3 bucket used to retailer archive logs. - Take away the cron entry from the EC2 occasion configured in Step 4b.
- Delete the S3 bucket that was created in Step 2a to retailer Oracle RMAN archive log backups.
Conclusion
On this publish, we display tips on how to use AWS Backup and Oracle RMAN Archive log backup of Oracle databases working on Amazon EC2 can restore and get well effectively to a point-in-time, with out requiring an extra-step of restoring knowledge recordsdata. Knowledge recordsdata are restored as a part of the AWS Backup EC2 occasion restoration. You possibly can leverage this resolution to facilitate restoring copies of your manufacturing database for growth or testing functions, plus get well from a person error that removes knowledge or corrupts current knowledge.
To study extra about AWS Backup, consult with the AWS Backup AWS Backup Documentation.