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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 備份與恢復:polardb資料庫備份與恢復資料庫
- 資料庫備份恢復資料庫
- DB2備份與恢復DB2
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- PostgreSql資料庫的備份和恢復SQL資料庫
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- Mysql資料庫備份及恢復MySql資料庫
- 達夢資料庫備份恢復資料庫
- postgresql備份與恢復資料庫SQL資料庫
- db2備份恢復(backup restore)DB2REST
- RMAN備份與恢復測試
- 資料庫備份與恢復技術資料庫
- Mongo 資料庫備份和恢復命令Go資料庫
- pg_dump 備份,恢復資料庫資料庫
- 【PG備份恢復】pg_basebackup 多表空間備份恢復測試
- db2 命令列備份和恢復DB2命令列
- Linux下MySQL資料庫的備份與恢復LinuxMySql資料庫
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- vivo 資料庫備份恢復系統演化資料庫
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- MySQL-19.資料庫備份與恢復MySql資料庫
- PG-pg_dump備份/恢復資料庫資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- Dedecms資料庫恢復與備份的兩種方法資料庫
- 淺談達夢資料庫的備份與恢復資料庫
- gitlab的資料備份和恢復Gitlab
- NoSQL 資料庫案例實戰 -- MongoDB資料備份、恢復SQL資料庫MongoDB
- RMAN備份恢復典型案例——資料庫卡頓資料庫
- Mysql資料備份與恢復MySql
- mysqldump使用方法(MySQL資料庫的備份與恢復)MySql資料庫
- apiAutoTest: 介面自動化測試的資料清洗(備份/恢復)處理方案API
- 如何恢復Hyper Backup備份的資料
- 【PG備份恢復】pg_dump命令測試
- 時序資料庫InfluxDB之備份和恢復策略資料庫UX
- 時序資料庫 InfluxDB 之備份和恢復策略資料庫UX
- ClickHouse資料庫單機安裝及備份恢復資料庫
- RabbitMQ如何備份與恢復資料MQ
- 磁碟資料恢復及備份工具資料恢復
- DB2資料庫自動備份方法TRDB2資料庫