0% found this document useful (0 votes)
13 views13 pages

Backup in DB

The document outlines two types of backup modes: Hot (online) and Cold (offline), with Cold backup being outdated due to business downtime concerns. It details backup strategies including Full and Incremental backups, explaining their processes and advantages, particularly the efficiency of Incremental backups for large databases. Additionally, it discusses the importance of archivelog management and proper storage locations for backups to ensure data recovery and system integrity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views13 pages

Backup in DB

The document outlines two types of backup modes: Hot (online) and Cold (offline), with Cold backup being outdated due to business downtime concerns. It details backup strategies including Full and Incremental backups, explaining their processes and advantages, particularly the efficiency of Incremental backups for large databases. Additionally, it discusses the importance of archivelog management and proper storage locations for backups to ensure data recovery and system integrity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

BACKUP TYPE

- We have two types of Back_up Mode.


▪ Hot Back_up
• Also called-
▪ Online back_up
▪ Open back_up
▪ Inconsistent back_up
▪ Cold Back_up
• Also called-
▪ Offline Back_up
▪ Close back_up
▪ consistent back_up
- Cold back_up is an out_dated method now, it is not used anymore as no
one wants to have downtime of the business

Back_up Strategy
- we have two types of strategies:
o Whole DB back_up
▪ Means we take all datafiles
▪ Control files
▪ Parameter file
▪ Archivelog file
▪ Meaning, everything seems to be important here, the
complete database.
▪ As many tablespaces as there are in a database and as
many datafiles as there are, they all matter.
▪ Meaning, take out all the business data you have
▪ Business data is stored in tablespace and tablespace is
stored in datafile.
▪ There is never a direct backup of a REDOLOG file, but
there is a backup of an archive log file and the archive
log file itself is a copy of the redolog file.
o Partial back_up
▪ It means, backup_up of a particular tablespace
▪ Backup of one or two datafiles

- We have two types of back_up:


BACKUP TYPE
o Full backup
▪ Full back_up means all used blocks in database.
▪ Every datafile contains blocks, and it is not necessary
that every block contains data.
▪ Meaning, if there is 1GB and out of that 200MB is used,
then only those are called used blocks..
▪ Applicable for both- full and partial back-up
o Incremental back up
▪ Backup of all used blocks that has changed since previous
backup.
▪ Suppose, there is a database, it has tablespaces and
their datafiles are there.
▪ Now everyone has their own blocks.
▪ assume that we only have 4 database files right now..
▪ And suppose, not all of them are present in each database
file, but some blocks are used.
▪ Now, ab full backup perform kartey hain.

Now, let us perform a full backup.

Full back up performed

Day1 day2 day3 day4 day5


day6

- Now, when you do a full backup in day1 it will pick up all the used
blocks.
- Now let's come to day 2 - Now after that if there is some change in
the dub then when there is a backup in the 2nd day then it will pick
all the used blocks only.
- Here we keep removing the previous backup..
- Here, if it took 1 hour on Day 1, then it will take more time on the
next day, meaning the time will keep increasing every day.
- And where there are small databases, full backup runs there.

Incremental backup performed

Day1 day2 day3 day4 day5


day6

- Whatever happens in full back on day 1 in incremental will happen in


incremental as well and this is called level-0 backup and we also
call it base backup.
- And on the basis of this base back up we create incremental strategy.
- Now when we go to take incremental backup on day 2 - it will first
look at the previous backup to see what all has changed, and whatever
has changed after the previous one, just pick that and it continues
running in the same way.
- Here we have to maintain the previous backup as well, meaning we
cannot remove it.
- But the thing here is that whatever time it takes at 0 level will be
taken, but whatever change will be raised after that, it will take
only a little time for that and it will get it done quickly.
- So where there is big database size we do it incrementally only.
- All the backups after 0 are level 1 backups. (1 means differential
backup - means backup of difference)
- Now that we have a level 0 backup, we can delete all the previous
backups.
- Level 0 means all used blocks
Full database backup
- To start RMAN first set SID.
- . oraenv ORCL
- Rman target /
- We can check like- report schema; in this we can see- tablespaces,
datafile name.
- Has RMAN taken any backup in the past, if you want to see this then
cmd is - List Backup;
- Report need backup; With cmd you are asking Raman whether I should
take Bakup or not.

-
- So this just shows whether these datafiles should be backed up or
not.
- So the command to take backup is - BACKUP DATABASE; and along with it
the control file and parameter file also get backed up.
- backup database plus archivelog; This command backs up the archive
and the rest of the database.
- Now ab baat kartey hain ki full backup mein aur kya kya command hoti
hain
- backup tablespace users; - You can back up any tablespace.
- Backup datafile ‘/u02/oradata/ORCL/users01.dbf’ - You have taken
backup of any data file, or you can also write down the number -
backup datafile 7;
- backup archivelog all delete input; - This command will backup all
archives and delete them..
- Deleting means that now if I go to the archive folder, I won't find
even one - cd /u02/archive
- Meaning first take a backup as per below:
-
- Then I placed it just below the location and deleted it also.
-
- As I don't want my mount point to be full so in this case, I will
also do a cleanup after taking the backup.
- So for that I will schedule it every 6 hours - backup archivelog all
delete input;

INCREMENTAL
dekhtey hain

- Backup incremental level 0 database - means when you take backup for
the first time, you will take 0 only (in incremental case - means
base backup)
- 1,2,3,4- these all are also called differential backups.
- Level 0, and 1- The advantage of all these is that next time whenever
you go to take backup of level 1, it will first check all the
previous levels and will only pick the changes that have happened
since then.
- Now I took incremental backup here - backup incremental level 0
database then exited. Then do ls -ltrh
/u01/app/oracle/product/19c/dbhome_1/dbs/093mhbnv_1_1 and checked the
size and found that the size is this - 1.3G as per below:

-
- Now, I'll open the second session.
- Create one table
- col tname for a30
- select * from tab;
- create table t101 as select * from dba_tables;
- insert into t101 (select * from t101);
- /
- /
- /
- /
- /
- /
- /
- /
- /
- commit;
- Now let's check the size of t101- select byte/1024/1024 from
user_segments where segment_name=’t101’;
- Meaning, this much change has happened here since the last backup.
- Now connect to rman- rman target /
- backup incremental level 1 database;
- exit
- ls -ltrh /u01/app/oracle/product/19c/dbhome_1/dbs/093mhbnv_1_1
- Now you will know what is the size of level 1 backup.
- So this is the advantage of incremental back_up.
Now,
let see that why we save the archivelog
- Now let's make a strategy under:
▪ Every Sunday- level 0 backup (at 10PM)
▪ Everyday level 1 backup (at 10PM)
▪ Every 12 hr archive backup on daily basis
- Now, I took a level 0 backup Sunday.
- Now as soon as you take level 0 backup, you can face problem anytime.
- Suppose level 0 backup is done on Sunday at 10 PM to 2 AM, now next
backup will be done on Monday.
- Now suppose the problem can occur anytime on Monday, suppose at some
time the problem occurred and one of the data files got deleted
accidentally.
- Now if it gets deleted then the application team will stop getting
data and everybody will go crazy.
- So now you have to do recover
- Whatever recovery you do at any time, we need two things:
- First is Backup and second is Archivelog.
- recovery=backup + archivelog + current redolog
- So we had a Sunday level 0 backup so we restored that first.
- So when you restore, you will get the data only till Sunday night.
- So from where will you get the data after that? - so, all that data
is recorded by us - in archive log and redo log.
- So these log, where can we find them, we have saved them, where have
we kept them, it will be in two places, one in backup and some inside
/u02/archive.
- So RMAN automatically knows this thing, so RMAN will pick it up from
there and also from the current redolog file.
- Now in the second scenario, suppose the backup was done on Monday
night and on Tuesday morning a problem occurred and a datafile got
deleted.
- How will I recover now, so now I have both level 0 and level 1
backups.
- So the first thing we will do is to restore the level 0 backup and
the level 1 backup will also be restored.
- When the restore happens then it means I got the data till Monday.
- Now we need the data till current time so at that time I will require
log - archive log + current redo log
- So now I don't need log from Sunday or Monday because I already have
that much backup.
- Meaning, suppose Sunday's level is 0, Monday's level is 1, Tuesday's
level is 1 and if a problem occurs on Wednesday then how will you
recover.
- So the simple answer is - first of all we will do the resotration
from Sunday till Tuesday and after that we will need log from level 1
to current time for Tuesday.
- Second, suppose I only have Sunday's level 0 backup and Monday and
Wednesday, no level 1 backup, what will you do now?
- So the answer is – I will restore the backup from Sunday level 0 and
then from Sunday I will need the log till current time.
- Meaning, you need the log after the date till which you have the
backup- this is how you understand
- One advantage of incremental is that requirement of log is very less.
So this is the reason why we need to save archives.

Where to store
the backup
- The backup we ran is going to be called by-default - going to the dbs
folder inside Oracle Home.
- This is the location of Oracle Binary, you cannot store backup here
at any cost.
- Because this location is small in itself like 50 or 100 GB, and the
backup of the DBB can be made of 200 or 300 GB or even 1 TB.
- It will exit with an error of insufficient space.
- For Raman's Backup we take separate mountpoint from the storage team
- Now they will ask you what is the size of the dab, so check it..
- DB size is measured at two levels:
▪ Logical database size
▪ select sum(bytes)/1024/1024/1024 from dba_segments;


▪ Physical database size
▪ Calculating the size of all the data files in the
database.
▪ select sum(bytes)/1024/1024/1024 from dba_data_files;

- Whenever you take space, space requirement is related to physical


space only, so double the amount of available space is required..
- So that's why there should be a separate mountpoint for backup -
mkdir /u02/backup

-
- Now start the RMAN – rman target /
- Now how do we put the backup in that location.
- Whatever backup you have taken for that, first backup the list - list
backup;
- This cmd tells you which type of backup has been taken as per below:-

-
- Like- full back or incremental- level 0 or 1, everything is shown in
it, a unique number is also given which is called backup set.
- So every time a backup is done, a backup set is created and it placed
backup piece in it..
- In one backup piece, it stores all files backup.
- Now find out from this cmd whether you need to take backup or not -
Report Need Backup; as per below:
-
- Now delete the entire backup - Delete Backup; - This process will
delete the entire backup from HD also..
- But, we don't usually use this cmd..
- So as soon as you delete, you will see that all your backups will be
deleted from this location also:
- cd /u01/app/oracle/product/19c/dbhome_1/dbs/
- ls -ltrh
- now, there is no backup.
- Now let's see how the bacup we take is inserted at the backup
location.
- For that cmd is- backup database format
'/u02/backup/ORCL_Full_Bkp_%U.rman'; (We can give this name
ourselves and add RMAN so that it can be identified that this is
RMAN's backup - ORCL_Full_Bkp_%U.rman)
- So, as Per Below Bacup was performed It also went to the mentioned
location:

-
- But, as per below, the backup of the control file and server
parameter is still going to the old location:

-
- So to control this first type this - show all;
- Now as per below, there are highlighted commands, that's why we get
the line shown in the above screenshot..
-
- So, this cmd says that- CONFIGURE CONTROLFILE AUTOBACKUP ON; #
default that switch on the backup of CF, means, whenever we take
backup so,by-default backup of CF and SP file’s location is
this=/u01/app/oracle/product/19c/dbhome_1/dbs/c-1725481645-20250410-
01
- So to change this location there is a parameter below it, so add your
path in that parameter where you want to keep it.

-
- CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/u02/backup/Controlfile_Backup_%F’; It is mandatory to use %F esle
not able to set this because %F provide uniqueness.
- As per below, location is set now.

-
- Now run the cmd- backup database format
'/u02/backup/ORCL_Full_Bkp_%U.rman'; And now it has moved to the
edited location along with CF and SP files.

-
- Set it for incremental in the same way:
- backup incremental level 0 database format
'/u02/backup/ORCL_Full_level0_Bkp_%U.rman';

-
- Now you can run this command for any command.:
- backup archivelog all format '/u02/backup/ORCL_ARCH_&U.rman';
-
- Now let's see how this will perform.
- Supppose you run this command- backup archivelog all format
'/u02/backup/ORCL_ARCH_&U.rman';
- So now if you look below, only one channel is starting to perform
this backup, that means a process:

-
- Meaning, whenever RMAN has some work to do, it will starts a channel
(process) to do that work, then that poor guy is using that one
process to do the entire backup.
- So in such a case, if there is only one process then it can take more
time.
- So I saw that only one process of mine is working, it will take a lot
of time, so what did I say, if one process will take a lot of time,
then now I will install 2 processes to get the work done.
- Toh aap yeh dekhogey ki aapke paas kitne number of CPU yaa number of
cores idle hain Then you will see how many number of letters or
number of courses you have- lscpu
-

-
- Like we have 4 cpu here, I can use 50% for backup, because backup is
done in our business hours only.
- Because by default only one channel is allowed to work, so how can 4
channels be used, there are two ways for this.
- 1st way hai:
- show all;
- So there is a cmd below this, just make it 2 instead of 1, the rest
will remain as it is and run the cmd.

-
- CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;

-
- Now run any one incremental cmd

-
- So now here the two channels have divided the work amongst themselves
and have started working.
- But usually people don't touch this cmd.
- So then how do you do it?.
- Toh jis level ka BKUP perform kartey hain usike hisaab se channel
allocate kartey hain.
- But I want that for incremental we allocate 2 and for full also
allocate 2, that means I want that for separate work I allocate 2 for
each.
- So in this case we need to write backup cmd within curly braces:
run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup archivelog all format '/u02/backup/ORCL_ARCH_&U.rman';
}
➢ You can give any name to the channel.
➢ Disk means, it will be taken to HD.
➢ And that cmd which you want to run.
- So this is how to take backup by manually allocating the channel and
that's how we do it.
- Whatever backup information we take from RMAN, it creates its
relation with CF inside the target database.

You might also like