13. Backup - sayanbhattacharya1234/Oracle_DBA GitHub Wiki

Backup process

Backup = A backup is a copy of datas that is used to restore or recover the database in the event of data loss, corruption and hardware faliures.

Backups are 2 types (a) Physical backup , (b) Logical backup. In PHYSICAL BACKUP is two type (a.1) Cold Backup , (a.2) Hot Backup

.

(a) Physical Backup : These backup means when we taking backup of a database when it is mount state block by block means copies of the actual phisical files used to store and restore the database. physical files including datafiles ,spfile ,pfile, control files, archived redo log files. this is reliable recovery strategy.

we cannot take backup of single tables backup , individual schemas backup, single row backup

interview qs [ suppose we are taking a physical backup and the database size 2TB so what will be the backup size? ans== is 2TB itself

size of backup = physical backup size is same as database backup size.

.

The backup repository of physical backup is control file.

For Taking backup we are useing a tool is called RMAN [ Recovery Manager ]

With Rman tool ,we can take backup of spfile ,control file, archived log files, we can take backup of individual datafile , we can take backup of tablespace . in rman is stored as a binary file.

.

we taking backup of a database when it is mount state , Rman tool when it takes backup but the backup is stored every all the repository is inside control file, all info is stored in control files.

first and formost rule is when we are taking backup , the database must be up and running , and the database must be archived log mode ,if it is not archived log mode you cannot take rman backup.it will through error.

(b) Logical Backup : These backup means when we are taking backup of a full database , it contains logical data such as single tables backup , individual schemas backup, single row backup . This backup is converted into dump file but inside that it will be sql statements written in binary , stored in sql format.

Schema : When we create an user this is user. and when this user create a table or any object then it is known as schema.

.

(a.1) Cold Backup (OFFLINE) : It performed when database is shut down and we are taking the backup. means normally in linux cp copy the datafiles and paste somewhere else that time database should be shut down. in industries we never take this backup , it is rare to perform. take lot of time to copy.

.

(a.2) Hot Backup(ONLINE) : It performed when the database is up and running , and you are taking the backup . mostly or regularly we take hot backup.

Process of backup

1st set the enviroment

command [ $ rman target / ] ( / means = root user login)

RMAN> list backup;

RMAN> crosscheck backup;

RMAN> backup database; [ taking Full backup ]

RMAN> list backup;

RMAN> crosscheck backup;

.

location of backup

Location of datafiles is '/u01/app/oracle/fast_recovery_area/PROD/backupset/'

location of spfile and controlfiles '/u01/app/oracle/fast_recovery_area/PROD/autobackup/'

if i delete the backup of datafiles from backupset

here the backupset backup is expired

deleted the backup file thats shows 'EXPIRED' from crosscheck backup command

if backup file shows 'ABSOLUET' , when we cannot restore from backup

delete the expired backup command delete expired backup;

command === backup database plus archivedlog;

we take a backup only archivelog by command === backup archivelog; ( for save the space and remove the archivelog because it take lot of space )

list backup;

i can take backup of individual file also.

so backup datafile 7;

i can take backup of tablespace

backup tablespace system;

assume i delete a datafile of users

rm users01.dbf

now what to do.

command ==== restore tablespace 7;

restore means