Monday, August 3, 2015

DB2 Online backup and restoration example

C:\Program Files\IBM\SQLLIB\BIN>db2 connect to sampledb

C:\Program Files\IBM\SQLLIB\BIN>db2 get db config |findstr LOGRETAIN
 Log retain for recovery enabled             (LOGRETAIN) = OFF

C:\Program Files\IBM\SQLLIB\BIN>db2 get db config |findstr LOGARCHMETH1
 First log archive method                 (LOGARCHMETH1) = OFF


C:\Program Files\IBM\SQLLIB\BIN>db2 update db config using logretain "recovery"

C:\Program Files\IBM\SQLLIB\BIN>db2 update db config using logarchmeth1 "disk:c:\DB2\Logs"

C:\Program Files\IBM\SQLLIB\BIN>db2stop force

C:\Program Files\IBM\SQLLIB\BIN>db2start


C:\Program Files\IBM\SQLLIB\BIN>db2 backup database sampledb online to "d:\backup" include logs without prompting

Backup successful. The timestamp for this backup image is : 20150803223509

C:\Program Files\IBM\SQLLIB\BIN>db2 force application all

C:\Program Files\IBM\SQLLIB\BIN>db2 restore database sampledb from "d:\backup" taken at 20150803223509

C:\Program Files\IBM\SQLLIB\BIN>db2 rollforward database sampledb to end of backup and complete

                                 Rollforward Status

 Input database alias                   = sampledb
 Number of nodes have returned status   = 1

 Node number                            = 0
 Rollforward status                     = not pending
 Next log file to be read               =
 Log files processed                    = S0000004.LOG - S0000005.LOG
 Last committed transaction             = 2015-08-03-14.35.14.000000 UTC

DB20000I  The ROLLFORWARD command completed successfully.

No comments:

Post a Comment