You are on page 1of 10

Database Backup

We need to back up following components :

Data files

control files, spfiles [ ALTER DATABASE backup controlfile to trace; ]

Archive logs [ we can backup manually or RMAN]

Password file

Network Files (tnsnames.ora, listener.ora)

Oracle Home - Any of your scripts

In order to perform database backup you need to have your database in ARCHIVE MODE.
To check if your database is in archive mode or not you need to fire the below sql
statement :
SELECT log_mode from V$DATABASE;

As you can see currently my database is NOT in archive mode. So let it first set it up in archive
mode.

Configure Archive Log Mode


Before we configure our DB in archive log mode we need to understand certain parameters
mentioned below:
1. Log_Archive_Dest :

Oracle allows you to have up to 10 destinations where you can have your Archive Log
created.

Either of the way you can mention the path of archive log to reside:
LOG_ARCHIVE_DEST_1='Location=/full/path/to/log/directory'
OR
LOG_ARCHIVE_DEST_2='Service=Standby'

2. Log_Archive_Format:

It is the way how your archive log looks.

Log_Archive_Format='ARC%S_%R.%T'
%S = sequence number
%R= Incarnation of database like once you first setup your database then it is 1st
incarnation if you reset the log it going to be 2nd incarnation and so on
%T=Thread number used while archiving.
3. Log_Archive_Dest_State:

If you want to dynamically enable or disable your archive log destination then you
need to use this parameter which should be set either enable or disable.

LOG_ARCHIVE_DEST_STATE_1 =enable

4. Log_Archive_Start:

This parameter is deprecated in 10g, so it just specifies whether your database is


archiving when you first set it up. It could be either True or False.

5. Log_Archive_Max_Processes:

Maximum number of processes that required to perform database archiving.


Log_Archive_Max_Processes =2

6. Log_Archive_Min_Succeed_Dest:

This signifies min number of destination required in order to you database succeed.
Log_Archive_Min_Succeed_Dest =1

7. Log_Archive_Trace:

Default it is set to 0 which means , we are not tracing any archiving activity. Higher
the number higher tracing information.

Now let me check what my database settings currently holding up.


Show parameter log_archive;

The log_archive_dest

the one without number is the oldest version of oracle and is used for

backward compatibility.
Now after verifying the log_archive parameters, we are going to configure the acrhive mode to our
database. For that we need to do:

shutdown immediate;

Now we are going to start our database in mount mode.


What happens when our database is opened in No mount mode - it initializes up the background
processes and SGA memory structure. Only the instance is created however database cannot be
queried as it is not initialized as well as the control files have not yet been read although they might
be present in init.ora file.
when we open in mount mode t reads up with control file and knows where all the datafile are
present. Control file has pointers that provide connection b/w Data files, Redo Logs, Archived Logs,
Memory and Last Updated SCN.
After opening database in mount mode, we need to alter database archivelog and open database as
given below, once we tried to open database it will make modification to control file and also
updating the data file headers .
startup mount;
alter database archivelog;
alter database open;

Now check if database archive logging is turned on :


SELECT log_mode from V$DATABASE;

If you have notice in our log_archive_dest_n parameter do not have any destination specified. So
now we need to set up the archive log path.
ALTER SYSTEM SET log_archive_dest_1='location= C:\oracle\product\10.2.0\admin\orcl\arch';

We will alter system and switch log file so that we can see if our archiving is happening properly or
not .

ALTER SYSTEM SWITCH logfile;

We must be using these archive logs to perform RECOVERY if anything goes wrong.

DATA FILES BACKUP


We have two types of backups for data files:
1) Hot Backups Backup datafiles either for tablespace or entire database, while database is up and running.
End User will not be affected by this backups.
This is great for 24 * 7 environment
Since with this we can backup entire database as well therefore it is not recommended for very
large database.

In oracle is going to generate more REDO information than normally it does.


FOR TABLE SPACE BACKUP:
ALTER TABLESPACE <table space name like USERS> BEGIN BACKUP;
ALTER TABLESPACE USER END BACKUP.
FOR DATABASE BACKUP:
ALTER DATABASE BEGIN BACKUP;
ALTER DATABASE END BACKUP;

When we issue above "begin backup"command- oracle will perform a checkpoint to flush stuffs from
memory to the data files.
Please note each datafile has header with SCN number and a control file has SCN number as well.
Therefore once this command is issued this going to freeze the SCN number even though the data
file are still written to , which is ok.

Hence we are done with hot backup.

2) Cold Backups We completely shutdown the database and copy the data files to the backed up location.

You might also like