Introduction to Oracle Backup Database
Oracle Backup Database as the name suggests can be defined as a database which is a copy of the original database which is required when we need to restore the original data in case of data loss due to natural disasters (earthquakes tsunami, floods, fire), manmade accidents (sudden deletion or format of the entire database or even terrorist activities like bomb blast and sabotage activities like virus attack, hardware theft) which provides us a safe and reliable and secure environment for the data of any business organizations or even personal data.
How to Create Backup Database in Oracle?
Let us now discuss about how we can create the backup in Oracle in this section and also understand the concept of Full Backup and Partial Backup. When we say Full Backup or whole database backup means that it is the backup of every data file present in the current database including the control file. It is the most common or most used backups. Next is partial backup is as the name suggests not a full backup. It is generally taken when the database is open or the database is shut down. It is also called an operating system backup. There are two types of backup methods in the case of the Oracle database. Let us look at them one by one.
Methods of Oracle Backup Database
Below are the two types of methods to create the Oracle Backup Database as follows:
1. Oracle Recovery Manager
Oracle Recovery Manager is a utility that is already present with the Oracle database. Since it is already present there is no need to download and install it externally. So, now the question comes what is RMAN (Recovery Manager)? The answer to that question is it that it is a client-server application that uses the database server sessions to manage the backup and recovery of the database. The metadata about its operations are stored in a control file in the target database. Let us now look into the reasons why we should be using the Recovery manger.
- It makes the backups scalable and flexible.
- It manages the complexity of backup operations so the stress and activity of the customer or user is reduced.
- The backups are not proportional to the size of the database but they are proportional to the size of the transactions.
- The last important one is that it reduces the chances of human error.
One important requirement for RMAN is that it can be used for Oracle database version 8.0 and greater.
In the case of Recovery manger, we will try to get the backup of a target database. To fulfill the task we need to see the environment. The two important topics is the RMAN executable which is the executable file and the other important one is the target database. The target database is the database that the recovery manager is taking the backup of. Let us now start RMAN and execute it through this example.
First, we connect to the target database using the connect target command and this will start the RMAN. The third prompt asks for the password because we have not specified DBA so we need to give the password.
RMAN> CONNECT TARGET SYS@Nil
target database password: password
connected to target database NIL
The EXIT command helps us to quit the RMAN client.
2. User Managed Backup and Recovery
The alternative to the Recovery Manager is the strategy of User managed backup and recovery. In this strategy, we do not use the Oracle Recovery Manager. It is a very simple strategy that involves periodic backups of datafiles by the user and archived logs with OS commands. This strategy of backup can be either logical or physical. We can use export utility to make backups of logical objects like tables, views, stored procedures and stored functions. We can use Operating System utilities to create physical backups.
In general, the preferred approach is RMAN for backup which we discussed in the previous section but there are certain areas in which we can also use user managed backup in place of RMAN. Some of the situations where we can use this strategy are mentioned below.
- We are having an older version of the database and we want to migrate into the latest version but we do not want to migrate the legacy backup scripts.
- RMAN only supports backup for versions starting from 8.0 and above but for lower versions, we can use User managed backup.
- In case of some issue, all the RMAN backups are lost and then we have to use this method forcibly.
Let us now take a look at an example that involves the whole database. In this example, we will create a backup of the whole database. Let us look at the process of creating a backup.
- We need to shut down the database with NORMAL, IMMEDIATE, or TRANSACTIONAL options.
- To create a physical backup we will use an operating system utility that will create backups of all data files and control files. The control files will be specified by the parameter CONTROL_FILESpresent in the initialization parameter file.
- The important question now is how we find these files which were mentioned. We can find these files by doing a search for *.ora in the oracle home directory and its subdirectories.
- In this example, we will take the backup of the data files, control files of the database to the address /backup/backup_version1 as shown below.
% cp $ORACLE_HOME/oradata/target/*.dbf /backup/backup_version1
% cp $ORACLE_HOME/oradata/target/arch/* /backup/backup_version1 /arch
- In the end we can restart the database using the STARTUP command in SQL Plus.
In this article, we discussed the definition of the backup and the reasons we need to have the backup. Later on, we discussed in detail the two backup strategies that we use and also discussed an example along with the steps for each strategy.
This is a guide to Oracle Backup Database. Here we discuss the Introduction of Oracle Backup Database and its different methods along with the practical examples. You can also go through our suggested articles to learn more –