db2 restore例子

对于带有include logs的在线备份,如果需要在另外一台机器上恢复
$ pwd        
/home/db2inst1/Desktop
$ db2 backup db sample online include logs

Backup successful. The timestamp for this backup image is : 20170104063157
$ pwd
/home/db2inst1/Desktop
$ ls
SAMPLE.0.db2inst1.DBPART000.20170104063157.001
$ mkdir logs
$ pwd
/home/db2inst1/Desktop
$ ls
logs  SAMPLE.0.db2inst1.DBPART000.20170104063157.001
$ db2 restore db sample from /home/db2inst1/Desktop taken at 20170104063157 logtarget /home/db2inst1/Desktop/logs
SQL2539W  The specified name of the backup image to restore is the same as the
name of the target database.  Restoring to an existing database that is the
same as the backup image database will cause the current database to be
overwritten by the backup version.
Do you want to continue ? (y/n) y
DB20000I  The RESTORE DATABASE command completed successfully.
$ ls
logs  SAMPLE.0.db2inst1.DBPART000.20170104063157.001
$ cd logs
$ ls
NODE0000
$ db2 "rollforward db sample to end of logs and stop overflow log path (/home/db2inst1/Desktop/logs)"

                                 Rollforward Status

 Input database alias                   = sample
 Number of members have returned status = 1

 Member ID                              = 0
 Rollforward status                     = not pending
 Next log file to be read               =
 Log files processed                    = S0001543.LOG - S0001544.LOG
 Last committed transaction             = 2017-01-04-06.32.05.000000 Local

DB20000I  The ROLLFORWARD command completed successfully.

如果不想恢复数据库,而只想恢复备份介质中的日志
$ pwd
/home/db2inst1/Desktop
$ ls
logs  SAMPLE.0.db2inst1.DBPART000.20170104063157.001
$ db2 restore db sample logs from /home/db2inst1/Desktop logtarget /home/db2inst1/Desktop/logs
DB20000I  The RESTORE DATABASE command completed successfully.
$ cd logs
$ ls
NODE0000
$ cd N*
$ ls
LOGSTREAM0000
$ cd L*
$ ls
S0001543.LOG
$

请使用浏览器的分享功能分享到微信等