How do we backup a database that is in no-archive-log mode in Oracle
- How we enable Unified Auditing in Oracle Database - 7 October 2024
- What is PostgreSQL and how do we do a full installation - September 2, 2024
- How do we configure GoldenGate replication to read from Oracle Data Guard Standby - 2 August 2024
In this article we will analyze what it takes to take an offline backup of an Oracle database that is in no-archive-log mode.
As the base does not keep the redo logs as an archive, we do not have the option for online backup. Which means we'll have to close the base and have it on mount state (not accessible by users) during the Backup.
In order to take a backup in addition to the datafiles, we should also take a backup of the controlfile and spfile.
What is control file and spfile?
Control File
The control file is the file that contains the name of the base, the location of the base files and the current log sequence number (lsn) or otherwise the time the base is located.
SPFILE
The spfile contains the parameters needed to run the base instance. It contains information such as the name of the base, the resources it uses and the location of the control file. To edit it we should first have made a pfile (create pfile from spfile) based on it as we can only edit the pfile and not the spfile directly.
We have this feature by setting to RMAN (Oracle Recovery Manager) the order CONFIGURE CONTROLFILE AUTOBACKUP
ON
to automatically get every time we backup the base and to control file and the spfile to the default location.
The example
In the example we will take offline backup compressed into one single instance base (not belonging to RAC) using RMAN (the tool provided by Oracle for backup/restore) script.
First we will connect to the base with sqlplus.
sqlplus / as sysdba
We will close the base.
shutdown immediate
We'll pick her up mount state.
startup mount
We exit from sqlplus to build and run the script in RMAN.
exit
We create a file named param.rman with the corresponding parameters as below.
CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/folder/fra/backup/CONTROL_%Y_%M_%D_%F.bck'; CONFIGURE DEVICE TYPE DISK PARALLELISM 8 BACKUP TYPE TO compressed backupset ; CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/folder/fra/backup/data_%Y_%M_%D_%U.bck'; run { backup database filesperset 3; }
To run the script in RMAN we should have set the environment to ORACLE_SID and ORACLE_HOME. We can make all of the following as an executable file e.g. backup.sh.
export ORACLE_SID=db export ORACLE_HOME=/home/oracle/oracle/app export NLS_DATE_FORMAT='dd/mm/yyy hh24:mi' rman target / cmdfile=/home/oracle/param.rman log=/home/oracle/backuplog`date +%Y%m%d_%H%M`.log
After giving the appropriate permissions to the file (chmod) we run it.
nohup ./backup.sh &
When it is finished we connect again with sqlplus to open the database.
sqlplus / as sysdba
alter database open;