Site icon Nimesa

Protecting Oracle Database deployed on EC2 Instance- Part I

ORACLE server is one of the key components in the data center. It is critical to protecting the database on a periodic basis. Backup and recovery refer to the process of backing up data in case of a loss and setting up systems that allow that data recovery due to data loss. Backing up data requires copying and archiving computer data so that it is accessible in case of data deletion or corruption. Below are the different types of backups of ORACLE supports.

Oracle – Types of backup:-

The benefit of taking a hot backup is that the database is available for use while the backup is occurring and one can recover the database to any point in time. The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery process. For cold backups, the database does not require being in archive log mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.

Difference between Restore and Recovery:-

Restoring involves copying backup files from secondary storage (backup media) to disk. This can be done to replace damaged files or to copy/move a database to a new location. Recovery is the process of applying redo logs to the database to roll it forward.

Media recovery applies archived redo logs and online redo logs to recover the datafiles. Whenever a change is made to a data file, the change is first recorded in the online redo logs. Media recovery selectively applies the changes recorded in the online and archived redo logs to the restored datafile to roll it forward.

Unlike media recovery, Oracle performs crash recovery and instance recovery automatically after an instance failure. Crash and instance recovery recover a database to its transaction-consistent state just before instance failure. By definition, crash recovery is the recovery of a database in a single-instance configuration or an Oracle Real Application Clusters configuration in which all instances have crashed.

Basic Recovery steps (Rolling forward and Rolling back):-

 

For managing production database is it mandatory to put the database in archive log mode.

How to take “App Aware” Oracle DB backup files using Nimesa?

Nimesa takes the snapshot of EBS volumes. Below steps describes how to take application consistent snapshot of Oracle databases using Nimesa pre and post scripts.

The first step is to create an Oracle App aware policy through “Application Policy” screen.

Upload the pre and post scripts.

“pre-db.sh” file Usage

Description:- Script is designed for DB to make it run on a hot backup mode. It is a pre-backup shell script which connects to the database, Quiesce and puts the database into “begin backup” mode.

Pre-req:-

“pre-db.sh” script modification:-

###Connecting to the bash shell prompt

#!/bin/bash

###Connecting to oracle user, Oracle instance ID from root user

orauser=”oracle”

orasid=”dummy”

###Setting the Oracle home path, getting it as input from the user

orahome=”/u02/app/oracle/product/11.2.0/db_1″

###Swtich User to Oracle and set ORACLE_SID and ORACLE_HOME based on orasid and orahome parameters

su – ${orauser}   << BOF 2>&1

export ORACLE_SID=$orasid

export ORACLE_HOME=$orahome

###Connect to SQLPLUS as sysdba and execute oracle commands needed for backup the DB

sqlplus “/ as sysdba” << EOF 2>&1

alter system archive log current;

alter database begin backup;

exit;

EOF

BOF

“post-db.sh” file Usage

Description:- Script is designed for DB to end its hot backup mode. It is a post-backup shell script which connects to the database and puts the database into “end backup” mode.

“post-db.sh” script modification:-

#!/bin/bash

orauser=”oracle”

orasid=”dummy”

orahome=”/u02/app/oracle/product/11.2.0/db_1″

#source /home/$orauser/$orasid.env

source /home/$orauser/.bash_profile

su – ${orauser}   << BOF 2>&1

export ORACLE_SID=$orasid

export ORACLE_HOME=$orahome

###Connecting to Oracle as sysdba and execute Oracle commands needs to end the DB backup

sqlplus “/ as sysdba” << EOF 2>&1

alter system archive log current;

alter database end backup;

alter system archive log current;

alter system switch logfile;

alter system switch logfile;

exit;

EOF

BOF

Create a backup group in Nimesa add the EC2 instance and assign the newly created policy. Trigger a scheduled or on demand backup as part of job progress the script excecution output will be seen.

Pre-Script Logs:

Post-Script Logs:

About Nimesa

Nimesa is an enterprise-class Application Aware data protection, cost management & copy data management Solution for applications running on AWS. It uses native AWS capabilities like EBS snapshots capabilities to automatically protect the environment. Nimesa provides simple policy based lifecycle management of snapshots and clones of EC2 instances