® ibm software group © ibm corporation quy thai duy – itfac dlu [email protected],...

16
® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU [email protected], [email protected] Lesson 7: Movement, backup and restore data

Upload: amina-cammack

Post on 02-Apr-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

®

IBM Software Group

© IBM Corporation

QUY Thai Duy – ITFac [email protected], [email protected]

Lesson 7: Movement, backup and restore data

Page 2: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Agenda

Data movement overview

Export

Import

Backup

Restore

Page 3: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Data Movement Tools

Page 4: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Data Movement Tools EXPORT, IMPORT, LOAD

IXF, DEL, ASC

db2move Easily export/import/load/copy set of tables & data (IXF)

db2look Extracts:

DDL

permissions

database statistics

Tablespace characteristics

Page 5: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

EXPORT

Export data based on SQL Statement

Page 6: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Launching the EXPORT Table Dialog

Control Center > (expand) All Databases folder > (select) Tables Folder > (right-click) Table > Export

Page 7: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

IMPORT High-speed SQL INSERT

Activates triggers

All Constraints enforced immediately

Uses BUFFERPOOL

IMPORT FROM employee.ixf OF IXFREPLACE_CREATEINTO employee_copy

Page 8: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Launching the IMPORT Dialog

Control Center > (expand) All Databases folder > (select) Tables Folder > (right-click) Table > Import

Page 9: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

LOAD Very High Speed, low level data loader

separate LOAD, BUILD, DELETE phases

Uses utility heap (UTIL_HEAP_SZ)

Does NOT use bufferpool and does NOT activate triggers

Constraints enforced as separate step, may define

EXCEPTION tables

online LOAD supported

Page 10: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Launching the LOAD Wizard

Control Center > (expand) All Databases folder > (select) Tables Folder > (right-click) Table > Load

Page 11: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Database Backup

Point-in-time image of a database

Backup example (try it now!):

BACKUP DB sample TO C:\BACKUPS

Page 12: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Example of Backup File Names

Page 13: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Database Recovery A database restore will recreate the database from a backup

The database will exist as it did at the time the backup completed

If archival logging were used before the database crash, it would then be possible to roll forward through the log files to reapply any changes since the backup was taken. It is possible to roll forward either to the end of the logs or to a specific

point in time.

The granularity available on the last transaction needs to be weighed against database performance.

Page 14: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Recovery Types

Crash/Restart Recovery Uses the RESTART DATABASE command or the automatic restart

enable configuration parameter (autorestart) to protect a database from being left in an inconsistent, or unusable, state.

Version/Image Recovery BACKUP & RESTORE commands to put the database in a state that

was previously saved (data since last backup lost).

Rollforward Recovery BACKUP & RESTORE and ROLLFORWARD commands to recover a

database to a specified point in time (minimal data loss).

Page 15: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Database Restore

Restore example:

drop db sample

RESTORE DB sample FROM <path>TAKEN AT 20060314131259

Page 16: ® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU quytd@dlu.edu.vn, thaiduyquy@gmail.com Lesson 7: Movement, backup and restore data

IBM Software Group

Also possible with BACKUP and RESTORE

Restore over existing database

Clone database from a backup image (redirected restore) http://www7b.boulder.ibm.com/dmdd/library/techarticle/0211melnyk/0211melnyk.html

Backup by tablespace

Restore only tablespace from full backup image

Delta and Incremental Backups

Backup from flash copy

Recovery of dropped tables