DB2資料庫的備份測試--開始恢復
1、察看備份集
[db2inst1@db2 off_back]$ db2 list history backup all for sample
List History File for sample
Number of matching file entries = 6
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20090917043647000 F S0000000.LOG
----------------------------------------------------------------------------
Contains 4 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 IBMDB2SAMPLEREL
00004 IBMDB2SAMPLEXML
----------------------------------------------------------------------------
Comment: DB2 BACKUP SAMPLE OFFLINE
Start Time: 20090917043647
End Time: 20090917043648
Status: A
----------------------------------------------------------------------------
EID: 4 Location:
SQLCA Information
sqlcaid : SQLCA sqlcabc: 136 sqlcode: -2036 sqlerrml: 14
sqlerrmc: /home/off_back
sqlerrp : sqlubMWR
sqlerrd : (1) 0 (2) 0 (3) 0
(4) 0 (5) 0 (6) 0
sqlwarn : (1) (2) (3) (4) (5) (6)
(7) (8) (9) (10) (11)
sqlstate:
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20090917043704001 F D S0000000.LOG S0000000.LOG
----------------------------------------------------------------------------
Contains 4 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 IBMDB2SAMPLEREL
00004 IBMDB2SAMPLEXML
----------------------------------------------------------------------------
Comment: DB2 BACKUP SAMPLE OFFLINE
Start Time: 20090917043704
End Time: 20090917043709
Status: A
----------------------------------------------------------------------------
EID: 5 Location: /home/db2inst1/off_back
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20090917061052001 N D S0000000.LOG S0000000.LOG
----------------------------------------------------------------------------
Contains 4 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 IBMDB2SAMPLEREL
00004 IBMDB2SAMPLEXML
----------------------------------------------------------------------------
Comment: DB2 BACKUP SAMPLE ONLINE
Start Time: 20090917061052
End Time: 20090917061059
Status: A
----------------------------------------------------------------------------
EID: 8 Location: /tmp/db2inst1/sample/on_back
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20090917061511001 O D S0000001.LOG S0000001.LOG
----------------------------------------------------------------------------
Contains 4 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 IBMDB2SAMPLEREL
00004 IBMDB2SAMPLEXML
----------------------------------------------------------------------------
Comment: DB2 BACKUP SAMPLE ONLINE
Start Time: 20090917061511
End Time: 20090917061512
Status: A
----------------------------------------------------------------------------
EID: 11 Location: /tmp/db2inst1/sample/diff_back
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20090917061921001 N D S0000002.LOG S0000002.LOG
----------------------------------------------------------------------------
Contains 4 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 IBMDB2SAMPLEREL
00004 IBMDB2SAMPLEXML
----------------------------------------------------------------------------
Comment: DB2 BACKUP SAMPLE ONLINE
Start Time: 20090917061921
End Time: 20090917061925
Status: A
----------------------------------------------------------------------------
EID: 14 Location: /tmp/db2inst1/sample/off_back
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
B D 20090917062532001 O D S0000005.LOG S0000005.LOG
----------------------------------------------------------------------------
Contains 4 tablespace(s):
00001 SYSCATSPACE
00002 USERSPACE1
00003 IBMDB2SAMPLEREL
00004 IBMDB2SAMPLEXML
----------------------------------------------------------------------------
Comment: DB2 BACKUP SAMPLE ONLINE
Start Time: 20090917062532
End Time: 20090917062535
Status: A
----------------------------------------------------------------------------
EID: 21 Location: /tmp/db2inst1/sample/off_back
2、尋求恢復幫助:
[db2inst1@db2 off_back]$ db2ckrst -d sample -t 20090917062532 -r database
Suggested restore order of images using timestamp 20090917062532 for
database sample.
====================================================================
restore db sample incremental taken at 20090917062532
restore db sample incremental taken at 20090917061921
restore db sample incremental taken at 20090917062532
3、開始恢復:
[db2inst1@db2 off_back]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917062532
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 off_back]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917061921
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 off_back]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917062532
DB20000I The RESTORE DATABASE command completed successfully.
4、恢復日誌
1、基於日誌恢復:
[db2inst1@db2 NODE0000]$ cd C0000000
[db2inst1@db2 C0000000]$ ls
S0000000.LOG S0000001.LOG S0000002.LOG S0000003.LOG S0000004.LOG S0000005.LOG
[db2inst1@db2 C0000000]$ cd ..
[db2inst1@db2 NODE0000]$ cp -r C0000000 /tmp
[db2inst1@db2 NODE0000]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917062532
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 NODE0000]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917061921
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 NODE0000]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917062532
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 NODE0000]$ db2 "rollforward database sample to end of logs and complete overflow log path (/tmp/C0000000/)"
Rollforward Status
Input database alias = sample
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000005.LOG - S0000026.LOG
Last committed transaction = 2009-09-17-23.15.10.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
2、基於時間恢復:
[db2inst1@db2 ~]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917062532
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 ~]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917061921
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 ~]$ db2 restore db sample incremental from /tmp/db2inst1/sample/off_back taken at 20090917062532
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst1@db2 ~]$ db2 "rollforward database sample to 2009-09-17-06.25.32 and complete overflow log path (/tmp/db2inst1/sample/archivelog/)"
Rollforward Status
Input database alias = sample
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000005.LOG - S0000007.LOG
Last committed transaction = 2009-09-16-23.15.13.000000 UTC
DB20000I The ROLLFORWARD command completed successfull
備註預設為格林尼治時間,所以需要如下:
1 rollforward 命令 to end of logs 選項是會回滾db cfg中logpath配置路徑下的所有已提交事務。而您是在原庫上直接restore操作的,所以原配置路徑下的日誌還存在。則您在前滾操作的時候,就連同這些日誌一併前滾了。您可以嘗試刪除資料,再次指定路徑前滾,確認日誌結束日誌編號。
2 to time_stamp USING LOCAL TIME 中 time_stamp 的時間格式為 yyyy-mm-dd-hh.mm.ss (year, month, day, hour, minutes, seconds)。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8334342/viewspace-616035/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DB2資料庫的備份測試--開始備份DB2資料庫
- DB2備份恢復測試DB2
- DB2的資料庫備份與恢復DB2資料庫
- DB2資料庫的備份和恢復DB2資料庫
- db2備份和恢復資料庫DB2資料庫
- 【備份恢復】從備份恢復資料庫資料庫
- rman備份恢復-rman恢復資料檔案測試
- Oracle資料庫的熱備份與完整恢復測試 (2)Oracle資料庫
- Oracle資料庫的熱備份與完整恢復測試 (1)Oracle資料庫
- 資料庫恢復到備份之前測試_RMAN-06556資料庫
- 備份與恢復:polardb資料庫備份與恢復資料庫
- mysql備份恢復測試MySql
- DB2資料庫的備份測試--備份環境變數配置DB2資料庫變數
- 資料庫的備份與恢復資料庫
- 淺談DB2資料庫的備份與恢復(下) (轉)DB2資料庫
- 資料庫資料的恢復和備份資料庫
- 【備份恢復】noarchive模式下使用增量備份恢復資料庫Hive模式資料庫
- 第5章:從開啟的資料庫備份與恢復之從開啟的資料庫備份中完全恢復資料庫
- Oracle DG從庫 Rman備份恢復測試Oracle
- PostgreSql資料庫的備份和恢復SQL資料庫
- mysql的資料庫備份與恢復MySql資料庫
- oracle資料庫的備份與恢復Oracle資料庫
- 第5章:從開啟的資料庫備份與恢復之備份開啟的資料庫資料庫
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- 達夢資料庫備份恢復資料庫
- postgresql備份與恢復資料庫SQL資料庫
- mongo資料庫備份與恢復Go資料庫
- Informix資料庫備份與恢復ORM資料庫
- 備份和恢復postgreSQL資料庫SQL資料庫
- Mysql資料庫備份及恢復MySql資料庫
- DB2備份與恢復DB2
- PDM測試資料庫恢復資料庫
- 關閉資料庫的備份與恢復資料庫
- Oracle資料庫的備份與恢復(轉)Oracle資料庫
- Oracle 資料庫的備份與恢復(轉)Oracle資料庫
- rman資料庫全庫備份與恢復資料庫
- DB2傻瓜1000問(十二)12、DB2資料庫的備份和恢復DB2資料庫
- RMAN備份恢復——RAC環境資料庫的備份(zt)資料庫