SlideShare une entreprise Scribd logo
1  sur  33
IBM Software Group
© 2005 IBM Corporation
DB2 UDB Intermediate
Day5
IBM Software Group
© 2005 IBM Corporation
Topics
 Backup
 Restore
 Load
 Import
2
IBM Software Group
© 2005 IBM Corporation
BACKUP
You can choose to backup entire database or one or more table
spaces from within the database.
You can also choose whether you want the backup to be taken
online or offline.
These options can be combined to give you a very flexible recovery
mechanism for your databases.
3
IBM Software Group
© 2005 IBM Corporation
Online and Offline Backup
 An online backup allows other applications or processes to
connect to the database as well as read modify the data while the
operation is running.
 An offline backup does not allow other applications or processes
to access the database and their objects while the operation is
being performed.
4
IBM Software Group
© 2005 IBM Corporation
Database Backup
5
 A database backup is a complete copy of your database objects. In
addition to the data, a backup copy contains information about the
table spaces, containers, the system catalog,database config file,
the log control file, and the recovery history file.
 Important note is that a backup does not contain the dbm cfg file or
the value of registry variables.
 You must have SYSADM, SYSCTRL, or SYSMAINT authority to
perform a backup.
IBM Software Group
© 2005 IBM Corporation
Commands for Backup
6
 db2 backup db dbname
Db2 backup sample
to /db2backup/dir1, /db2backup/dir2
WITH 4 BUFFERS
BUFFER 4096
PARALLELISM 2
• There is no keyword for OFFLINE in the syntax, as this is the
default mode.
IBM Software Group
© 2005 IBM Corporation
 Db2 BACKUP DATABASE sample ONLINE TO /dev/rdir1, /dev/rdir2
INCLUDE LOGS
 db2 backup db test on all dbpartitionnums
 db2 backup db test on dbpartitionnums (0, 3)
 db2 backup db test on all dbpartitionnums except dbpartitionnums
(1,2)
 db2 backup db test on all dbpartitionnums online INCLUDE LOGS
7
IBM Software Group
© 2005 IBM Corporation
Table Space Backup
8
In a database where only some of your table spaces change
considerably, you may opt not to back up the entire database but
only specific table spaces. To perform a table space backup, you
can use the following syntax.
 Db2 BACKUP DATABASE sample TABLESPACE (syscatspace,
userspace1, userspace2) ONLINE TO /db2tbsp/backup1,
/db2tbsp/backup2
IBM Software Group
© 2005 IBM Corporation
Types of Backup
 An incremental backup is a backup image that contains only pages
that have been updated since the previous backup was taken.
 In delta backups, DB2 backs up only the data that has changed
since the last successfull, cumulative, or delta backup.
 For incremental backups, if there was a crash after the incremental
backup on Friday, you would restore the first Sunday’s full backup,
followed by the incremental backup taken on Friday.
 For delta backups, if there was a crash after the delta backup on
Friday, you would restore the first Sunday’s full backup, followed
by each of the delta backups taken on Monday through Friday
inclusive.
9
IBM Software Group
© 2005 IBM Corporation
Incremental and Delta Backup
10
IBM Software Group
© 2005 IBM Corporation
Trackmod Parameter
 To enable incremental and delta backups, the TRACKMOD
database configuration parameter must be set to YES. This allows
DB2 to track database modifications so that the backup utility can
detect which database pages must be included in the backup
image. After setting this parameter to YES, you must take a full
database backup to have a baseline against which incremental
backups can be taken.
 BACKUP DB sample INCREMENTAL TO /dev/
 BACKUP DB sample INCREMENTAL DELTA TO /dev/rdir1
11
IBM Software Group
© 2005 IBM Corporation
Backup Files
The backup images are stored as files. The name of the backup file
contains the following parts:
• Database alias
• Type of backup (0=Full database, 3=Table space, 4=Copy from
LOAD)
• Instance name
• Database partition (always NODE0000 for a single-partition
database)
• Catalog partition number (always CATN0000 for a single-partition
database)
• Timestamp of the backup
• The image sequence number
12
IBM Software Group
© 2005 IBM Corporation
Backup file sample
13
IBM Software Group
© 2005 IBM Corporation
Restore
 You can restore a database backup image and create a new database or
you can restore over top of an existing database. You need SYSADM,
SYSCTRL, or SYSMAINT authority to restore into an existing database,
and SYSADM or SYSCTRL authority restore to a new database.
 RESTORE DATABASE sample FROM C:DBBACKUP
 TAKEN AT 20070428131259
 WITHOUT ROLLING FORWARD
 WITHOUT PROMPTING
14
IBM Software Group
© 2005 IBM Corporation
 If database has archival log enabled .a restore operation puts the
database in to roll forward pending state. Regardless of whether
the backup was online or offline .
 RESTORE DATABASE sample FROM C:DBBACKUP
LOGTARGET C:DB2NODE0000SQL00001SQLOGDIR
Table space Restore :
 RESTORE DATABASE sample (1)
 TABLESPACE ( mytblspace1 ) (2)
 ONLINE (3)
 FROM /db2tbsp/backup1, /db2tbsp/backup2 (4)
15
IBM Software Group
© 2005 IBM Corporation
DB2 IMPORT UTILITY
The import utility inserts data from an input file into a table or a
view. The utility performs inserts as if it was executing INSERT
statements.
 import from employee.ixf of ixf
messages employee.out
insert into employee
Messages option is used to record error, warning messages as
well as the import status.
16
IBM Software Group
© 2005 IBM Corporation
Import Modes
17
IBM Software Group
© 2005 IBM Corporation
Some useful options for Import Utility
 warningcount
 Rowcount
1. import from employee.del of del messages empsalary.out
warningcount 10 replace into empsalary (salary, bonus, comm)
2. import from employee.ixf of ixf messages employee.out
rowcount 1000 replace_create into newemployee
3. import from employee.ixf of ixf messages newemployee.out
create into newemployee in datats index in indexts
18
IBM Software Group
© 2005 IBM Corporation
More Useful options for Import
 allow write access – to allow concurrent read/write access to
tables.
 allow no access- table will be locked exclusively.
 commit count – to enforce a commit after every n records imported.
Example :import from employee.ixf of ixf
commitcount 1000
messages newemp.out
create into newemployee in datats index in indexts
19
IBM Software Group
© 2005 IBM Corporation
Output of log file
20
IBM Software Group
© 2005 IBM Corporation
Restarting failed Import
If you have import failures due to invalid input, for example, you
can use the message file generated from an import command that
uses the commitcount and messages options to identify which
record failed. Then you could issue the same import command with
restartcount n or skipcount n to start the import from record n+1.
This is a very handy
 method to restart a failed import. Here is an example:
import from employee.ixf of ixf commitcount 1000
skipcount 550
messages newemployee.out
create into newemployee in datats index in indexts
21
IBM Software Group
© 2005 IBM Corporation
Load Utility
In db2, Load process completes in 4 phases:
• Load
• Build
• Delete
• Index copy
22
IBM Software Group
© 2005 IBM Corporation
Load Phase
 During the load phase, the load utility scans the input file for any
invalid data rows that do not comply with the table definition; for
example, if a table column is defined as INTEGER but the input data
is stored as “abcd”. Invalid data will not be loaded into thetable.
and index keys are also collected.
23
IBM Software Group
© 2005 IBM Corporation
Build Phase
 During the build phase, indexes are produced
based on the index keys collected during the load
phase. The index keys are sorted during the load
phase, and index statistics are collected (if the
statistics use profile option was specified).
24
IBM Software Group
© 2005 IBM Corporation
Delete Phase
 In the load phase, the utility only rejects rows that do not comply
with the column definitions.
 Rows that violated any unique constraint will be deleted in the
delete phase.
 Note that only unique constraint violated rows are deleted. Other
constraints are not checked during this phase or during any load
phase. You have to manually check it after the load operation is
complete.
25
IBM Software Group
© 2005 IBM Corporation
Index Copy Phase
 During the index copy phase, index data is copied
from a system temporary table space to the
original table space. This will only occur if a
system temporary table space was specified for
index creation during a load operation with the
read access option
26
IBM Software Group
© 2005 IBM Corporation
Messages , Savecount and Warning count Option
 messages option is used to record warnings and errors
encountered during the load operation.
 The savecount option establishes consistency points after every
1,000 rows are loaded.
 Warningcount option will stop when the threshold of warnings is
encountered.
 load from stock.del of del
savecount 1000
warningcount 10 messages stock.out
insert into stock(itemid, itemdesc, cost, inventory)
27
IBM Software Group
© 2005 IBM Corporation
Restart and Termination of Load Utility
 Consistency points are established during the load phase. You can
use them to restart a failed or terminated load operation. By
specifying the same load command but replacing insert with the
restart option, the load operation will automatically continue from
the last consistency point.
 To terminate a load, issue the same load command but use the
terminate option in place of insert;
load from stock.del of del
savecount 1000
warningcount 10
messages stock.out terminate
28
IBM Software Group
© 2005 IBM Corporation
Modified by dumpfile option
 load from stock.ixf of ixf
 modified by dumpfile=stockdump.dmp
 messages stock.out
 replace into stock
29
IBM Software Group
© 2005 IBM Corporation
 As mentioned earlier, the load process goes through four phases.
During the load phase, data that does not comply with the column
definition will not be loaded. Rejected records can be saved in
 a dump file by using the modified by dumpfile modifier. If dumpfile
is not specified,
 rejected records are not saved. Since the load utility will not stop
unless it reaches the warning
 threshold if one is specified, it is not easy to identify the rejected
records. Hence, it is always a good practice to use the modifier and
validate the message file after a load is completed.
30
IBM Software Group
© 2005 IBM Corporation
Important Point
 The load utility checks for invalid data and unique constraints
during the load process. However, other constraints such as
referential integrity and check constraints are not validated. DB2
therefore puts target tables defined with these constraints in check
pending state. This forces you to manually validate the data before
the tables are available for further processing
31
IBM Software Group
© 2005 IBM Corporation
The COPY YES/NO Options
 Recall that changes made to the target tables during the load are
not logged. This is one of the characteristics of the load utility that
improves performance. However, it also takes away the ability to
perform roll forward recovery for the load operation. DB2 puts the
table space where the target table resides in backup pending state
when the load operation begins.
 After the load completes, you must back up the table space or
database. This ensures that the table space can be restored to the
point where logging is resumed . This is the behavior of the load
option copy no.
 You can also specify copy yes if archival logging is enabled. With copy yes,
a copy of the loaded data will be saved and the table space will not be in
backup pending state upon load completion.
32
IBM Software Group
© 2005 IBM Corporation
Thank You
33

Contenu connexe

Tendances

Understanding DB2 Optimizer
Understanding DB2 OptimizerUnderstanding DB2 Optimizer
Understanding DB2 Optimizerterraborealis
 
IBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration BasicsIBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration BasicsIBM
 
IBM DB2 LUW UDB DBA Online Training by Etraining.guru
IBM DB2 LUW UDB DBA Online Training by Etraining.guruIBM DB2 LUW UDB DBA Online Training by Etraining.guru
IBM DB2 LUW UDB DBA Online Training by Etraining.guruRavikumar Nandigam
 
The Top 12 Features new to Oracle 12c
The Top 12 Features new to Oracle 12cThe Top 12 Features new to Oracle 12c
The Top 12 Features new to Oracle 12cDavid Yahalom
 
Db2 Important questions to read
Db2 Important questions to readDb2 Important questions to read
Db2 Important questions to readPrasanth Dusi
 
DB2 LUW Access Plan Stability
DB2 LUW Access Plan StabilityDB2 LUW Access Plan Stability
DB2 LUW Access Plan Stabilitydmcmichael
 
Dbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easyDbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easyFranck Pachot
 
All types of backups and restore
All types of backups and restoreAll types of backups and restore
All types of backups and restoreVasudeva Rao
 
db2dart and inspect
db2dart and inspectdb2dart and inspect
db2dart and inspectdbawork
 

Tendances (20)

Understanding DB2 Optimizer
Understanding DB2 OptimizerUnderstanding DB2 Optimizer
Understanding DB2 Optimizer
 
IBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration BasicsIBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration Basics
 
IBM DB2 LUW UDB DBA Online Training by Etraining.guru
IBM DB2 LUW UDB DBA Online Training by Etraining.guruIBM DB2 LUW UDB DBA Online Training by Etraining.guru
IBM DB2 LUW UDB DBA Online Training by Etraining.guru
 
Les 10 fl1
Les 10 fl1Les 10 fl1
Les 10 fl1
 
Les 18 space
Les 18 spaceLes 18 space
Les 18 space
 
The Top 12 Features new to Oracle 12c
The Top 12 Features new to Oracle 12cThe Top 12 Features new to Oracle 12c
The Top 12 Features new to Oracle 12c
 
Db2 Important questions to read
Db2 Important questions to readDb2 Important questions to read
Db2 Important questions to read
 
DB2 utilities
DB2 utilitiesDB2 utilities
DB2 utilities
 
Les 12 fl_db
Les 12 fl_dbLes 12 fl_db
Les 12 fl_db
 
Les 04 config_bu
Les 04 config_buLes 04 config_bu
Les 04 config_bu
 
DB2 LUW Access Plan Stability
DB2 LUW Access Plan StabilityDB2 LUW Access Plan Stability
DB2 LUW Access Plan Stability
 
Les 00 intro
Les 00 introLes 00 intro
Les 00 intro
 
Les 16 resource
Les 16 resourceLes 16 resource
Les 16 resource
 
Dbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easyDbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easy
 
All types of backups and restore
All types of backups and restoreAll types of backups and restore
All types of backups and restore
 
Les 05 create_bu
Les 05 create_buLes 05 create_bu
Les 05 create_bu
 
db2dart and inspect
db2dart and inspectdb2dart and inspect
db2dart and inspect
 
IBM Utilities
IBM UtilitiesIBM Utilities
IBM Utilities
 
Les 06 rec
Les 06 recLes 06 rec
Les 06 rec
 
Xpp c user_rec
Xpp c user_recXpp c user_rec
Xpp c user_rec
 

En vedette

201512 132 e-portafolio
201512 132 e-portafolio201512 132 e-portafolio
201512 132 e-portafoliooctavio1471
 
Benamor.belgacemبرهان دويكات 0
 Benamor.belgacemبرهان دويكات 0 Benamor.belgacemبرهان دويكات 0
Benamor.belgacemبرهان دويكات 0benamor belgacem
 
4° básico b semana del lunes 26 al 30 de septiembre
4° básico b semana del lunes 26    al 30 de septiembre4° básico b semana del lunes 26    al 30 de septiembre
4° básico b semana del lunes 26 al 30 de septiembreColegio Camilo Henríquez
 
ملاحم و ازهار Benamor.belgacem
ملاحم و ازهار Benamor.belgacemملاحم و ازهار Benamor.belgacem
ملاحم و ازهار Benamor.belgacembenamor belgacem
 
Trad lazzarato biopoderbiopolitica
Trad lazzarato biopoderbiopoliticaTrad lazzarato biopoderbiopolitica
Trad lazzarato biopoderbiopoliticaEllemartinez
 
Roteiro O Sol a Lua e a Terra
Roteiro O Sol a Lua e a TerraRoteiro O Sol a Lua e a Terra
Roteiro O Sol a Lua e a Terrajomedia s.r.o.
 
4º básico a semana 26 de septiembre al 30 de septiembre
4º básico a  semana  26 de septiembre al 30 de septiembre4º básico a  semana  26 de septiembre al 30 de septiembre
4º básico a semana 26 de septiembre al 30 de septiembreColegio Camilo Henríquez
 
Auroras polares
Auroras  polaresAuroras  polares
Auroras polareserickandre
 
Benamor.belgacemمصر 2013 دراسة تحليلية لعملية التحول السياسي في مصر
 Benamor.belgacemمصر 2013 دراسة تحليلية لعملية التحول السياسي في مصر Benamor.belgacemمصر 2013 دراسة تحليلية لعملية التحول السياسي في مصر
Benamor.belgacemمصر 2013 دراسة تحليلية لعملية التحول السياسي في مصرbenamor belgacem
 
3 lecciones-aprendidas
3 lecciones-aprendidas3 lecciones-aprendidas
3 lecciones-aprendidasLuis Mojica
 

En vedette (16)

201512 132 e-portafolio
201512 132 e-portafolio201512 132 e-portafolio
201512 132 e-portafolio
 
5° básico a semana 26 al 30 de septiembre
5° básico a  semana 26 al 30 de septiembre5° básico a  semana 26 al 30 de septiembre
5° básico a semana 26 al 30 de septiembre
 
2° basico b semana del 05 al 09 de agosto
2°  basico b  semana del   05 al 09 de agosto2°  basico b  semana del   05 al 09 de agosto
2° basico b semana del 05 al 09 de agosto
 
Benamor.belgacemبرهان دويكات 0
 Benamor.belgacemبرهان دويكات 0 Benamor.belgacemبرهان دويكات 0
Benamor.belgacemبرهان دويكات 0
 
4° básico b semana del lunes 26 al 30 de septiembre
4° básico b semana del lunes 26    al 30 de septiembre4° básico b semana del lunes 26    al 30 de septiembre
4° básico b semana del lunes 26 al 30 de septiembre
 
ملاحم و ازهار Benamor.belgacem
ملاحم و ازهار Benamor.belgacemملاحم و ازهار Benamor.belgacem
ملاحم و ازهار Benamor.belgacem
 
Trad lazzarato biopoderbiopolitica
Trad lazzarato biopoderbiopoliticaTrad lazzarato biopoderbiopolitica
Trad lazzarato biopoderbiopolitica
 
Roteiro O Sol a Lua e a Terra
Roteiro O Sol a Lua e a TerraRoteiro O Sol a Lua e a Terra
Roteiro O Sol a Lua e a Terra
 
4º básico a semana 26 de septiembre al 30 de septiembre
4º básico a  semana  26 de septiembre al 30 de septiembre4º básico a  semana  26 de septiembre al 30 de septiembre
4º básico a semana 26 de septiembre al 30 de septiembre
 
Maneira de amar
Maneira de amar Maneira de amar
Maneira de amar
 
23 de abril lectura
23 de abril lectura23 de abril lectura
23 de abril lectura
 
Bazo
BazoBazo
Bazo
 
Auroras polares
Auroras  polaresAuroras  polares
Auroras polares
 
Benamor.belgacemمصر 2013 دراسة تحليلية لعملية التحول السياسي في مصر
 Benamor.belgacemمصر 2013 دراسة تحليلية لعملية التحول السياسي في مصر Benamor.belgacemمصر 2013 دراسة تحليلية لعملية التحول السياسي في مصر
Benamor.belgacemمصر 2013 دراسة تحليلية لعملية التحول السياسي في مصر
 
Entrevista dirigida
Entrevista dirigidaEntrevista dirigida
Entrevista dirigida
 
3 lecciones-aprendidas
3 lecciones-aprendidas3 lecciones-aprendidas
3 lecciones-aprendidas
 

Similaire à DB2 Intermediate Day5 Backup, Restore, Load and Import

Ibm db2 10.5 for linux, unix, and windows data movement utilities guide and...
Ibm db2 10.5 for linux, unix, and windows   data movement utilities guide and...Ibm db2 10.5 for linux, unix, and windows   data movement utilities guide and...
Ibm db2 10.5 for linux, unix, and windows data movement utilities guide and...bupbechanhgmail
 
Exam 1z0 062 Oracle Database 12c: Installation and Administration
Exam 1z0 062 Oracle Database 12c: Installation and AdministrationExam 1z0 062 Oracle Database 12c: Installation and Administration
Exam 1z0 062 Oracle Database 12c: Installation and AdministrationKylieJonathan
 
patchVantage Cloud Starter Pack
patchVantage Cloud Starter Pack patchVantage Cloud Starter Pack
patchVantage Cloud Starter Pack David McNish
 
RMAN in 12c: The Next Generation (WP)
RMAN in 12c: The Next Generation (WP)RMAN in 12c: The Next Generation (WP)
RMAN in 12c: The Next Generation (WP)Gustavo Rene Antunez
 
IBM Db2 11.5 External Tables
IBM Db2 11.5 External TablesIBM Db2 11.5 External Tables
IBM Db2 11.5 External TablesPhil Downey
 
MySQL Enterprise Backup - BnR Scenarios
MySQL Enterprise Backup - BnR ScenariosMySQL Enterprise Backup - BnR Scenarios
MySQL Enterprise Backup - BnR ScenariosKeith Hollman
 
HTG-SQL Server 2005 - Backup & Recovery.pdf
HTG-SQL Server 2005 - Backup & Recovery.pdfHTG-SQL Server 2005 - Backup & Recovery.pdf
HTG-SQL Server 2005 - Backup & Recovery.pdfSami Asmar
 
EDBT 2013 - Near Realtime Analytics with IBM DB2 Analytics Accelerator
EDBT 2013 - Near Realtime Analytics with IBM DB2 Analytics AcceleratorEDBT 2013 - Near Realtime Analytics with IBM DB2 Analytics Accelerator
EDBT 2013 - Near Realtime Analytics with IBM DB2 Analytics AcceleratorDaniel Martin
 
database backup and recovery
database backup and recoverydatabase backup and recovery
database backup and recoverysdrhr
 
Forms Playback: Unlocking Oracle's Hidden Tool for Fast Dataloads
Forms Playback: Unlocking Oracle's Hidden Tool for Fast DataloadsForms Playback: Unlocking Oracle's Hidden Tool for Fast Dataloads
Forms Playback: Unlocking Oracle's Hidden Tool for Fast DataloadsNikunj Sanghvi
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneDeepti Singh
 
CICS-COBOL to J2EE Migration – White Paper
CICS-COBOL to J2EE Migration – White PaperCICS-COBOL to J2EE Migration – White Paper
CICS-COBOL to J2EE Migration – White PaperKumaran Systems Inc
 
White Paper, System Z Dataset Naming Standards
White Paper, System Z Dataset Naming StandardsWhite Paper, System Z Dataset Naming Standards
White Paper, System Z Dataset Naming StandardsDan O'Dea
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
Keep data available without affecting user response time
Keep data available without affecting user response timeKeep data available without affecting user response time
Keep data available without affecting user response timePrincipled Technologies
 

Similaire à DB2 Intermediate Day5 Backup, Restore, Load and Import (20)

Ibm db2 10.5 for linux, unix, and windows data movement utilities guide and...
Ibm db2 10.5 for linux, unix, and windows   data movement utilities guide and...Ibm db2 10.5 for linux, unix, and windows   data movement utilities guide and...
Ibm db2 10.5 for linux, unix, and windows data movement utilities guide and...
 
Exam 1z0 062 Oracle Database 12c: Installation and Administration
Exam 1z0 062 Oracle Database 12c: Installation and AdministrationExam 1z0 062 Oracle Database 12c: Installation and Administration
Exam 1z0 062 Oracle Database 12c: Installation and Administration
 
patchVantage Cloud Starter Pack
patchVantage Cloud Starter Pack patchVantage Cloud Starter Pack
patchVantage Cloud Starter Pack
 
RMAN in 12c: The Next Generation (WP)
RMAN in 12c: The Next Generation (WP)RMAN in 12c: The Next Generation (WP)
RMAN in 12c: The Next Generation (WP)
 
IBM Db2 11.5 External Tables
IBM Db2 11.5 External TablesIBM Db2 11.5 External Tables
IBM Db2 11.5 External Tables
 
MySQL Enterprise Backup - BnR Scenarios
MySQL Enterprise Backup - BnR ScenariosMySQL Enterprise Backup - BnR Scenarios
MySQL Enterprise Backup - BnR Scenarios
 
Readme
ReadmeReadme
Readme
 
HTG-SQL Server 2005 - Backup & Recovery.pdf
HTG-SQL Server 2005 - Backup & Recovery.pdfHTG-SQL Server 2005 - Backup & Recovery.pdf
HTG-SQL Server 2005 - Backup & Recovery.pdf
 
EDBT 2013 - Near Realtime Analytics with IBM DB2 Analytics Accelerator
EDBT 2013 - Near Realtime Analytics with IBM DB2 Analytics AcceleratorEDBT 2013 - Near Realtime Analytics with IBM DB2 Analytics Accelerator
EDBT 2013 - Near Realtime Analytics with IBM DB2 Analytics Accelerator
 
database backup and recovery
database backup and recoverydatabase backup and recovery
database backup and recovery
 
DB2 Upgrade instructions
DB2 Upgrade instructionsDB2 Upgrade instructions
DB2 Upgrade instructions
 
Power point oracle db 12c
Power point oracle db 12cPower point oracle db 12c
Power point oracle db 12c
 
Upgrading 11i E-business Suite to R12 E-business Suite
Upgrading 11i E-business Suite to R12 E-business SuiteUpgrading 11i E-business Suite to R12 E-business Suite
Upgrading 11i E-business Suite to R12 E-business Suite
 
Forms Playback: Unlocking Oracle's Hidden Tool for Fast Dataloads
Forms Playback: Unlocking Oracle's Hidden Tool for Fast DataloadsForms Playback: Unlocking Oracle's Hidden Tool for Fast Dataloads
Forms Playback: Unlocking Oracle's Hidden Tool for Fast Dataloads
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid clone
 
CICS-COBOL to J2EE Migration – White Paper
CICS-COBOL to J2EE Migration – White PaperCICS-COBOL to J2EE Migration – White Paper
CICS-COBOL to J2EE Migration – White Paper
 
White Paper, System Z Dataset Naming Standards
White Paper, System Z Dataset Naming StandardsWhite Paper, System Z Dataset Naming Standards
White Paper, System Z Dataset Naming Standards
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Keep data available without affecting user response time
Keep data available without affecting user response timeKeep data available without affecting user response time
Keep data available without affecting user response time
 

DB2 Intermediate Day5 Backup, Restore, Load and Import

  • 1. IBM Software Group © 2005 IBM Corporation DB2 UDB Intermediate Day5
  • 2. IBM Software Group © 2005 IBM Corporation Topics  Backup  Restore  Load  Import 2
  • 3. IBM Software Group © 2005 IBM Corporation BACKUP You can choose to backup entire database or one or more table spaces from within the database. You can also choose whether you want the backup to be taken online or offline. These options can be combined to give you a very flexible recovery mechanism for your databases. 3
  • 4. IBM Software Group © 2005 IBM Corporation Online and Offline Backup  An online backup allows other applications or processes to connect to the database as well as read modify the data while the operation is running.  An offline backup does not allow other applications or processes to access the database and their objects while the operation is being performed. 4
  • 5. IBM Software Group © 2005 IBM Corporation Database Backup 5  A database backup is a complete copy of your database objects. In addition to the data, a backup copy contains information about the table spaces, containers, the system catalog,database config file, the log control file, and the recovery history file.  Important note is that a backup does not contain the dbm cfg file or the value of registry variables.  You must have SYSADM, SYSCTRL, or SYSMAINT authority to perform a backup.
  • 6. IBM Software Group © 2005 IBM Corporation Commands for Backup 6  db2 backup db dbname Db2 backup sample to /db2backup/dir1, /db2backup/dir2 WITH 4 BUFFERS BUFFER 4096 PARALLELISM 2 • There is no keyword for OFFLINE in the syntax, as this is the default mode.
  • 7. IBM Software Group © 2005 IBM Corporation  Db2 BACKUP DATABASE sample ONLINE TO /dev/rdir1, /dev/rdir2 INCLUDE LOGS  db2 backup db test on all dbpartitionnums  db2 backup db test on dbpartitionnums (0, 3)  db2 backup db test on all dbpartitionnums except dbpartitionnums (1,2)  db2 backup db test on all dbpartitionnums online INCLUDE LOGS 7
  • 8. IBM Software Group © 2005 IBM Corporation Table Space Backup 8 In a database where only some of your table spaces change considerably, you may opt not to back up the entire database but only specific table spaces. To perform a table space backup, you can use the following syntax.  Db2 BACKUP DATABASE sample TABLESPACE (syscatspace, userspace1, userspace2) ONLINE TO /db2tbsp/backup1, /db2tbsp/backup2
  • 9. IBM Software Group © 2005 IBM Corporation Types of Backup  An incremental backup is a backup image that contains only pages that have been updated since the previous backup was taken.  In delta backups, DB2 backs up only the data that has changed since the last successfull, cumulative, or delta backup.  For incremental backups, if there was a crash after the incremental backup on Friday, you would restore the first Sunday’s full backup, followed by the incremental backup taken on Friday.  For delta backups, if there was a crash after the delta backup on Friday, you would restore the first Sunday’s full backup, followed by each of the delta backups taken on Monday through Friday inclusive. 9
  • 10. IBM Software Group © 2005 IBM Corporation Incremental and Delta Backup 10
  • 11. IBM Software Group © 2005 IBM Corporation Trackmod Parameter  To enable incremental and delta backups, the TRACKMOD database configuration parameter must be set to YES. This allows DB2 to track database modifications so that the backup utility can detect which database pages must be included in the backup image. After setting this parameter to YES, you must take a full database backup to have a baseline against which incremental backups can be taken.  BACKUP DB sample INCREMENTAL TO /dev/  BACKUP DB sample INCREMENTAL DELTA TO /dev/rdir1 11
  • 12. IBM Software Group © 2005 IBM Corporation Backup Files The backup images are stored as files. The name of the backup file contains the following parts: • Database alias • Type of backup (0=Full database, 3=Table space, 4=Copy from LOAD) • Instance name • Database partition (always NODE0000 for a single-partition database) • Catalog partition number (always CATN0000 for a single-partition database) • Timestamp of the backup • The image sequence number 12
  • 13. IBM Software Group © 2005 IBM Corporation Backup file sample 13
  • 14. IBM Software Group © 2005 IBM Corporation Restore  You can restore a database backup image and create a new database or you can restore over top of an existing database. You need SYSADM, SYSCTRL, or SYSMAINT authority to restore into an existing database, and SYSADM or SYSCTRL authority restore to a new database.  RESTORE DATABASE sample FROM C:DBBACKUP  TAKEN AT 20070428131259  WITHOUT ROLLING FORWARD  WITHOUT PROMPTING 14
  • 15. IBM Software Group © 2005 IBM Corporation  If database has archival log enabled .a restore operation puts the database in to roll forward pending state. Regardless of whether the backup was online or offline .  RESTORE DATABASE sample FROM C:DBBACKUP LOGTARGET C:DB2NODE0000SQL00001SQLOGDIR Table space Restore :  RESTORE DATABASE sample (1)  TABLESPACE ( mytblspace1 ) (2)  ONLINE (3)  FROM /db2tbsp/backup1, /db2tbsp/backup2 (4) 15
  • 16. IBM Software Group © 2005 IBM Corporation DB2 IMPORT UTILITY The import utility inserts data from an input file into a table or a view. The utility performs inserts as if it was executing INSERT statements.  import from employee.ixf of ixf messages employee.out insert into employee Messages option is used to record error, warning messages as well as the import status. 16
  • 17. IBM Software Group © 2005 IBM Corporation Import Modes 17
  • 18. IBM Software Group © 2005 IBM Corporation Some useful options for Import Utility  warningcount  Rowcount 1. import from employee.del of del messages empsalary.out warningcount 10 replace into empsalary (salary, bonus, comm) 2. import from employee.ixf of ixf messages employee.out rowcount 1000 replace_create into newemployee 3. import from employee.ixf of ixf messages newemployee.out create into newemployee in datats index in indexts 18
  • 19. IBM Software Group © 2005 IBM Corporation More Useful options for Import  allow write access – to allow concurrent read/write access to tables.  allow no access- table will be locked exclusively.  commit count – to enforce a commit after every n records imported. Example :import from employee.ixf of ixf commitcount 1000 messages newemp.out create into newemployee in datats index in indexts 19
  • 20. IBM Software Group © 2005 IBM Corporation Output of log file 20
  • 21. IBM Software Group © 2005 IBM Corporation Restarting failed Import If you have import failures due to invalid input, for example, you can use the message file generated from an import command that uses the commitcount and messages options to identify which record failed. Then you could issue the same import command with restartcount n or skipcount n to start the import from record n+1. This is a very handy  method to restart a failed import. Here is an example: import from employee.ixf of ixf commitcount 1000 skipcount 550 messages newemployee.out create into newemployee in datats index in indexts 21
  • 22. IBM Software Group © 2005 IBM Corporation Load Utility In db2, Load process completes in 4 phases: • Load • Build • Delete • Index copy 22
  • 23. IBM Software Group © 2005 IBM Corporation Load Phase  During the load phase, the load utility scans the input file for any invalid data rows that do not comply with the table definition; for example, if a table column is defined as INTEGER but the input data is stored as “abcd”. Invalid data will not be loaded into thetable. and index keys are also collected. 23
  • 24. IBM Software Group © 2005 IBM Corporation Build Phase  During the build phase, indexes are produced based on the index keys collected during the load phase. The index keys are sorted during the load phase, and index statistics are collected (if the statistics use profile option was specified). 24
  • 25. IBM Software Group © 2005 IBM Corporation Delete Phase  In the load phase, the utility only rejects rows that do not comply with the column definitions.  Rows that violated any unique constraint will be deleted in the delete phase.  Note that only unique constraint violated rows are deleted. Other constraints are not checked during this phase or during any load phase. You have to manually check it after the load operation is complete. 25
  • 26. IBM Software Group © 2005 IBM Corporation Index Copy Phase  During the index copy phase, index data is copied from a system temporary table space to the original table space. This will only occur if a system temporary table space was specified for index creation during a load operation with the read access option 26
  • 27. IBM Software Group © 2005 IBM Corporation Messages , Savecount and Warning count Option  messages option is used to record warnings and errors encountered during the load operation.  The savecount option establishes consistency points after every 1,000 rows are loaded.  Warningcount option will stop when the threshold of warnings is encountered.  load from stock.del of del savecount 1000 warningcount 10 messages stock.out insert into stock(itemid, itemdesc, cost, inventory) 27
  • 28. IBM Software Group © 2005 IBM Corporation Restart and Termination of Load Utility  Consistency points are established during the load phase. You can use them to restart a failed or terminated load operation. By specifying the same load command but replacing insert with the restart option, the load operation will automatically continue from the last consistency point.  To terminate a load, issue the same load command but use the terminate option in place of insert; load from stock.del of del savecount 1000 warningcount 10 messages stock.out terminate 28
  • 29. IBM Software Group © 2005 IBM Corporation Modified by dumpfile option  load from stock.ixf of ixf  modified by dumpfile=stockdump.dmp  messages stock.out  replace into stock 29
  • 30. IBM Software Group © 2005 IBM Corporation  As mentioned earlier, the load process goes through four phases. During the load phase, data that does not comply with the column definition will not be loaded. Rejected records can be saved in  a dump file by using the modified by dumpfile modifier. If dumpfile is not specified,  rejected records are not saved. Since the load utility will not stop unless it reaches the warning  threshold if one is specified, it is not easy to identify the rejected records. Hence, it is always a good practice to use the modifier and validate the message file after a load is completed. 30
  • 31. IBM Software Group © 2005 IBM Corporation Important Point  The load utility checks for invalid data and unique constraints during the load process. However, other constraints such as referential integrity and check constraints are not validated. DB2 therefore puts target tables defined with these constraints in check pending state. This forces you to manually validate the data before the tables are available for further processing 31
  • 32. IBM Software Group © 2005 IBM Corporation The COPY YES/NO Options  Recall that changes made to the target tables during the load are not logged. This is one of the characteristics of the load utility that improves performance. However, it also takes away the ability to perform roll forward recovery for the load operation. DB2 puts the table space where the target table resides in backup pending state when the load operation begins.  After the load completes, you must back up the table space or database. This ensures that the table space can be restored to the point where logging is resumed . This is the behavior of the load option copy no.  You can also specify copy yes if archival logging is enabled. With copy yes, a copy of the loaded data will be saved and the table space will not be in backup pending state upon load completion. 32
  • 33. IBM Software Group © 2005 IBM Corporation Thank You 33

Notes de l'éditeur

  1. This presentation will discuss DB2 UDB Fundamentals.