Information Management Ecosystem Partnerships IBM Canada Lab
Summer/Fall 2010
DB2® Backup and Recovery
Managementt Information Managemen
© 2010 IBM Corporation
Inormation Mana!ement
"#y Backup my Data$ ■
Backing up data is vital for businesses % &o't inormation can cau'e a ma(or cri'i' or )or'e* lead to +u'ine'' ailure, ■
Common problems: % Sy'tem outa!e - .o)er ailure - ard)are ailure % ran'action ailure - 'er 'er' ' may in inadve adverten rtently tly co corrup rruptt t#e dat data+a' a+a'e e % Media ailure - Di' Di'k k dr drive ive + +eco ecome' me' u unu' nu'a+l a+le e % Di'a'ter - Data+ Data+a'e a'e a acility cility dama! dama!ed ed +y ire* loodin loodin! ! or ot#er cata'trop#e
DB2 backup and recovery methods are designed to help you keeping your information safe!
© 2010 IBM Corporation
2
Inormation Mana!ement
Ba'ic Concept o Data+a'e Backup and Recovery ■ ■
■
At t a database backup operation is performed At t2 a problem that damages the database occurs At t" all committed data is i s recovered
Data+a'e
Data+a'e
lo!'
at t1
at t1
Data+a'e continue' to proce'' tran'action', ran'action' are recorded in lo! ile'
t1 .erorm a data+a'e +ackup
data+a'e Backup Ima!e
3ter re'tore* reapply t#e tran'action' committed +et)een t1 and t2 u'in! t#e lo! ile',
t2 Di'a'ter 'trike'* Data+a'e i' dama!ed
t .erorm a data+a'e re'tore u'in! t#e +ackup ima!e, #e re'tored data+a'e i' identical to t#e data+a'e at t1
© 2010 IBM Corporation
Inormation Mana!ement
DB2 ran'action &o!' ■ ■
#eep track of changes made to database ob$ects and their data During the recovery process process DB2 e%amines these logs and decides &hich & hich changes to redo or undo
■
Can be stored in files or on ra& devices DB2 Memory 8in R3M9
■
'he transactions in the log buffer are recorded in the log device upon one of the follo&ing events: % &o! +uer i' ull % 5um+er o commit' reac# MI(C)MMI' MI(C)MMI' value value % 6ne 'econ 'econd d #a' lap'ed
.acka!e cac#e pdate tran'action
&o! Buer pdate tran'action
Buerpool .a!e inde7e' Inormation to +erom updated i' retrieved di'k 8i needed9
6ld tran'action'
Di'k or t#e data+a'e
4
Di'k or lo!'
© 2010 IBM Corporation
Inormation Mana!ement
&o! File State' ■
Active logs % ran'action' ran'action' t#at #ave not +een committed or rolled + +ack ack
■
)nline archive logs % Committed and e7ternali;ed e7ternali;ed lo!' in t#e active lo! directory
■
)ffline archive logs % Committed and e7ternali;ed e7ternali;ed lo!' in a 'eparate repo'itory DB2 Memory 8in R3M9 .acka!e cac#e pdate tran'action
&o! Buer pdate tran'action
Buerpool .a!e inde7e'to +e Inormation updated i' retrieved rom di'k 8i needed9
6ld tran'action'
6FF&I5< 3rc#ive &o!'
Di'k or t#e data+a'e
:
3ctive &o! Directory
© 2010 IBM Corporation
Inormation Mana!ement
Circular &o!!in! ■
*rimary log files used to record all transactions+ reused &hen transactions are committed
■
,econdary log files allocated &hen ne%t primary log file is not available due to active transactions
■
If both primary and secondary log limit are full and can not be reused a log full condition occurs and ,-./01C error message is returned
■
)nly full offline backups of the database are allo&ed
■
Cannot have roll3for&ard recovery
ran'action'
DB2 ,erver
3ctive lo! pat# 1 2
n
.rimary lo!'
1
n
3ctive lo! ile
Secondary lo!'
4
© 2010 IBM Corporation
=
Inormation Mana!ement
3rc#ival &o!!in! ■ ■
■
4nable &ith .)5A6C7M4'7 .)5A6C7M4'7 database database configuration parameter 7istory of log files is maintained in order to allo& roll for&ard recovery and online backup .ogs can be optionally archived to an archive location &hen no longer lon ger active to avoid e%haustion of log directory
"#en all preallocated lo! ile' are illed*more lo! ile' are allocated and u'ed, Filled lo! ile' may +e moved to a dierent 'tora!e location )(.I(4 A6C7I84 Contain' inormation or committed tran'action', Stored in t#e 3CI@< lo! 'u+directory,
AC'I84 % Contain' inormation AC'I84 % or non?committed tran'action',
3rc#ive &o! Directory
3ctive &o! Directory
© 2010 IBM Corporation
>
Inormation Mana!ement
Ininite &o!!in! ■
Infinite logging provides infinite active log space %<na+led % <na+led +y 'ettin! .)5,4C)(D to 3
■
,econdary log files are allocated until the unit of &ork commits or storage is e%hausted
■
Archived recovery logs can hinder performance for rollback and crash
■
Database must be configured to use archival logging
■
9p to 21 log files ;primary < secondary=
■
Control parameters %(9M>.)5>,*A( % (9M>.)5>,*A( % % num+er o lo! ile' an active tran'action can 'pan MA?>.)5 % % .ercenta!e o active primary lo! ile 'pace t#at a %MA?>.)5 % 'in!le tran'action could con'ume
© 2010 IBM Corporation
A
Inormation Mana!ement
Data+a'e Backup ■
■
Copy of a database or table space %'er % 'er data DB2 catalo!' %DB2 % %3ll % 3ll control ile'* e,!, e,!, +uer +uer pool ile'* ta+le 'pace ile* data+a'e coni!uration ile Backup modes: %)ffline % )ffline Backup - Doe' not all allo) o) ot#e ot#err application' application' or proce''e proce''e' ' to acce'' t#e data+a'e - 6nly op option tion )#en )#en u'in! u'in! circular circular lo!!in! lo!!in! )nline Backup %)nline % Backup application' or proce''e' to acce'' t#e - 3llo)' ot#er application' data+a'e - 3vaila+le to u'er' durin! +ackup - Can +acku +ackup p to di'k* tape* tape* SM SM and ot#er ot#er 'tora!e 'tora!e vendor' vendor'
© 2010 IBM Corporation
Inormation Mana!ement
Data+a'e Backup % Synta7 db2 backup database <db_nam database <db_name> e> <online> <online> to <dest_path> to <dest_p ath>
)nline backup e%ample
db2 backup database mydb database mydb online online to to /home/db2inst1/ /home/db2inst1/backups backups
)ffline backup e%ample db2 backup database mydb database mydb to to /home/db2inst1/ba /home/db2inst1/backups ckups
© 2010 IBM Corporation
10
Inormation Mana!ement
Data+a'e Backup % File 5amin! Convention
3lia'
In'tance
Catalo! 5ode
ear
Day Minute Seuence
SAMPLE..!"2#$S%.$&!E.'A%$ SAMPLE..!"2#$S%. $&!E.'A%$.21(1)1(12*+. .21(1)1(12*+.1 1 ype
Backup y ypeE peE 0 Full Backup a+le'pace Backup
5ode
Mont#
our Second
© 2010 IBM Corporation
11
Inormation Mana!ement
a+le 'pace Backup ■ ■
4nables user to backup a subset of database Multiple table table spaces can be specified Multiple
■
'able space backup can run in both online and online and offline backup offline backup
■
'able space can be restored from either a database backup or table space backup of the given table space
■
9se the key&ord 'AB.4,*AC4 to 'AB.4,*AC4 to specify table spaces
db2 backup database mydb1 %A"LESPA'E mydb1 %A"LESPA'E ,%"SP1- &$L#$E to to /home/db2inst1/backup
© 2010 IBM Corporation
12
Inormation Mana!ement
Incremental Backup' ,unday
Fu ll
Mon
'ue 'u e
ed
'hu
ri
,at
Cumulative
,unday
Fu ll
Backups Fu ll
Delta Backups
Fu ll
■
Incremental ;a@k@a@ cumulative cumulative== 3 Backup of all database data that has changed since the
■
most recent successful full backup operation Incremental Delta 3 Delta 3 Backup of all database data that has changed since the last successful backup ;full incremental or delta= operation@
■
'6AC#M)D database database configuration parameter )( (eed to have '6AC#M)D
■
,upports both database and table space backups@
■
,uitable for large databases considerable savings by only backing up incremental
changes@ © 2010 IBM Corporation
1
Inormation Mana!ement
Data+a'e Backup % Compre''ion ■
DB2 backups can no& be automatically compressed % Si!niicantly reduce +ackup +ackup 'tora!e co't'
■
*erformance characteristics % C. co't' typically increa'ed 8due to compre''ion computation9 % Media I/6 time typically decrea'ed decrea'ed 8due to decrea'ed decrea'ed ima!e 'i;e9 % 6verall +ackup/re'tore perormance perormance can increa'e or decrea'eG decrea'eG dependin! on )#et#er C. or media I/6 i' a +ottleneck
<7ampleE
db2 backup database !S2 to /home/db2inst1/backups compess
© 2010 IBM Corporation
14
Inormation Mana!ement
3utomatic Data+a'e Backup ■
,implifies database backup management tasks for the DBA by al&ays ensuring that a recent full backup of the database is performed as needed
■
'o configure automatic backup %5raphical % 5raphical user interface tools - Coni Coni!ure !ure 3utomatic utomatic Mainte Maintenance nance )i;ard
%Command % Command line interface - auto>db>backup - auto>maint
%,tored % ,tored procedure - A9')MAI('>,4'>*).IC 'y'tem A9')MAI('>,4'>*).IC 'y'tem 'tored procedure
© 2010 IBM Corporation
1:
Inormation Mana!ement
6ptimi;in! Backup .erormance ■
automatically configures configures these parameters for performance DB2 automatically % *arallelism - 5um+e 5um+err o ta+le ta+le 'pa 'pace' ce' +ac +acked ked up in pa paralle rallell % num>buffers - 5um 5um+er +er o +u +uer' er' u'e u'ed d - 'e at lea't t&ice as many buffers a' buffers a' +ackup tar!et' 8or 'e''ion'9 to en'ure t#at t#e +ackup tar!et device' do not #ave to to )ait or data, % Buffer - Ba Backu ckup p +u +u er er ' 'i; i;e e
■
Allocate more memory to backup utility by increasing i ncreasing utility heap sie
■
■
;9'I.>74A*>,E 9'I.>74A*>,E== configuration parameter@ parameter@ Backup subset of data &here possible: % a+le 'pace +ackup' % Incremental +ackup' 9se multiple target devices
© 2010 IBM Corporation
1=
Inormation Mana!ement
Data+a'e Recovery ■
6ecovery is the rebuilding of a database or table space after a problem such as media or storage failure po&er interruption or application failure@ 'ypes of 6ecovery
Crash or restart recovery %Crash % - .rote .rotect' ct' t#e data+a'e data+a'e rom +ein! +ein! let incon'i'ten incon'i'tentt 8po)er ailure9 6oll for&ard recovery %6oll % - <7ten <7tend' d' recovery recovery +y u'in! ull ull data+a'e data+a'e and ta+le ta+le 'pace +ackup in con(unction )it# t#e data+a'e lo! ile'
© 2010 IBM Corporation
1>
Inormation Mana!ement
DB2 Re'tore tility ■ ■
6estore utility is the complement of backup utility 6estores database or table space from a previously taken backup
■
A' 3 ,pecify the time stamp of the database backup 'A#4( A' 3 image@ Backup image timestamp is displayed after successful completion of a backup
■
prompting F F )verrides any &arnings@ ithout prompting Eample0
SAMPLE..!"2#$S%.$&!E.'A%$ SAMPLE..!"2#$S%.$&!E.'A%$. .211(121 211(121.1 .1 3ES%&3E !A%A"ASE dbalias 43&M <db_path> %A5E$ A% 2//G/HG"2/
© 2010 IBM Corporation
1A
Inormation Mana!ement
a+le 'pace Re'tore 6peration ■
6estored table space is in 6oll or&ard *ending state *ending state and can be either rolled for&ard to 4nd of .ogs .ogs or or a *oint In 'ime@ 'ime@ % In ca'e o .oint in ime ime roll or)ard* ta+le 'pace 'pace mu't +e rolled or)ard or)ard to at lea't t#e minimum *oint in 'ime
■
Minimum recovery time can be checked using
■
■
% db2 list tablespaces sho& detail 9ser table space must be in line &ith & ith catalog table space % e,! i catalo! indicate' ta+le 1 e7i't' e7i't' in ta+le 'pace S.1* ta+le 1 mu't e7i't in t#e S.1 ta+le t a+le 'pace* ot#er)i'e data+a'e +ecome' incon'i'tent 4very time there is a DD. changed minimum mi nimum recovery time for the table space is revised to indicate the last l ast DD. change@
■
6ecommended to take a table space backup after a table space has been restore to a point in time@
■
'ransactions that came after the point in time are lost therefore take a 'ransactions table space backup as ne& point of reference for future recoveries@ recoveries@
© 2010 IBM Corporation
1
Inormation Mana!ement
Incremental Re'tore ■ ■
6estore a database &ith incremental backup images A9')MA'IC ;recomended= 3 ;recomended= 3 All reuired backup images &ill be applied automatically by restore utility
■
MA(9A. MA(9A. F F 9ser applies the reuired backups manually db2ckrst can provide t#e 'euence or applyin! +ackup' % db2ckrst can
■
AB)6' 3 AB)6' 3 aborts an in3progress manual cumulative restore
■
64,')64 DA'ABA,4 sample I(C64M4('A. A9')MA'IC 6)M Jdb2backupJdir+
■
6)..)6A6D DA'ABA,4 sample ') 4(D ) .)5, A(D C)M*.4'4+
© 2010 IBM Corporation
20
Information Management Ecosystem Partnerships IBM Canada Lab
Summer/Fall 2010
Questions? E-mail:
[email protected] Subject: “DB2 Academic Wo!sho"#
Managementt Information Managemen