Updated June 30, 2023
Introduction to Oracle Backup Database
As the name suggests, Oracle Backup Database defines a database that serves as a copy of the original database. Its purpose is to facilitate the restoration of the original data in the event of data loss caused by various factors such as natural disasters (such as earthquakes, tsunamis, floods, or fires) and manmade accidents (including accidental deletion or formatting of the entire database, as well as acts of terrorism or sabotage such as virus attacks or hardware theft). This backup database ensures a safe, reliable, and secure environment for the data of any business organization or individual.
How to Create Backup Database in Oracle?
Let us now discuss how we can create the backup in Oracle in this section and understand the concept of Full Backup and Partial Backup. When we say Full Backup or whole database backup, 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 backup. 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 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 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 is stored in a control file in the target database. Let us now look into why we should use the Recovery manager.
- It makes the backups scalable and flexible.
- It manages the complexity of backup operations so that the stress and activity of the customer or user are 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 supports Oracle database version 8.0 and greater.
Example:
In the case of the Recovery manager, 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 are 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, which 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
RMAN> CONNECT TARGET SYS@Nil
target database password: password
connected to target database NIL
RMAN> EXIT
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 data files by the user and archived logs with OS commands. This strategy of backup can be either logical or physical. We can use the 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.
As discussed in the previous section, we generally prefer the RMAN approach for backup. However, there are certain areas where we can also opt to use user-managed backup instead of RMAN. Let’s explore some situations where this strategy can be employed:
- We have an older database version and want to migrate to 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 we can use User managed backup for lower versions.
- In the event of an issue where all the RMAN backups are lost, we are compelled to use this method forcefully.
Example:
Let us now look at an example involving the whole database. In this example, we will create a backup of the entire database. Let us look at the process of creating a backup.
- We must shut down the database with NORMAL, IMMEDIATE, or TRANSACTIONAL options.
- To create a physical backup, we will use an operating system utility to create backups of all data and control files. The parameter CONTROL_FILESpresent in the initialization parameter file will specify the control files.
- The important question now is how we can locate these mentioned files. We can find these files by searching for *.ora in the Oracle home directory and subdirectories.
- In this example, we will take the backup of the data files and 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
- Ultimately, we can restart the database using the STARTUP command in SQL Plus.
Conclusion
In this article, we discussed the definition of a backup and the reasons we need to have a backup. Later, we discussed in detail the two backup strategies we use, an example, and the steps for each strategy.
Recommended Articles
We hope that this EDUCBA information on the “Oracle Backup Database” was beneficial to you. You can view EDUCBA’s recommended articles for more information.