The following article mainly introduces some questions about DB2 Backup Recovery in actual operations. If you are curious about DB2 Backup recovery, the following article will unveil its mystery, the following is a description of the specific content. I hope it will be helpful for your future study.
After practicing DB2 backup and recovery, the online DB2 backup was successfully restored after several days.
Let me explain how I did it first.
Create a database testdb
- db2 create database testdb using codeset UTF-8 territory US
Enable online backup
- db2 update db cfg for testdb using userexit on logretain on trackmod on
Create Backup Directory
- mkdir /backup/db2inst1
- chown db2inst1:db2grp1 /backup/db2inst1
Restart the db2 instance for a cold backup with a timestamp of 20100224111110
- db2stop force
- db2start
- db2 backup db testdb to /backup/db2inst1
Create a database table
- create table T(
- a int,
- b int,
- c int
- )
Insert 100 data records in table T, 0, 0
Online backup with a timestamp of 20100224113029
- db2 backup db testdb online to /backup/db2inst1
View the first activity log, S00000001.LOG
- db2 get db cfg for testdb
Insert 100 data records in table T, 1
Online backup with a timestamp of 20100224113530
- db2 backup db testdb online to /backup/db2inst1
View the first activity log, S0000002.LOG
- db2 get db cfg for testdb
Delete 100, 0, 0
Copy all the archived logs and activity logs in the SQLOGDIR directory to the/temp directory.
Delete the entire testdb
- db2 drop db testdb
DB2 Backup recovery to the last backup point 20100224113530
- db2 restore database testdb from /backup/db2inst1 taken at 20100224113530
Copy all archived logs and activity logs to SQLOGDIR and change users and user groups.
- chown db2inst1:db2grp1 *
Log rollback
Because the backup timestamp date and the archiving log time seem a little different, my current practice is to first execute the following sentence to get a time, then rollforward can be rolled back at that time.
- db2 rollforward db testdb stop
After executing the preceding statement, the following message is displayed:
- SQL1276N Database "TESTDB" cannot be brought out of rollforward pending state
- until roll-forward has passed a point in time greater than or equal to
- "2010-02-24-03.12.34.000000 UTC", because node "0" contains information later
Than the specified time.
According to the prompts, get the time 2010-02-24-03.12.34.000000, and then rollforward to this time.
- db2 rollforward db testdb to 2010-02-24-03.12.34.000000 and stop
I don't know. Under normal circumstances, how do masters know when to roll back? For more information, see. Thank you!
I also found a situation during rollback: according to the activity log, DB2 backup can be used to restore the data between the fault point and the last backup point.
Write more time points later in rollforward.
- $ Db2 rollforward db testdb to 2010-02-24-03.15.00 and stop
- Then he will prompt SQL4970N Roll-forward recovery on database "TESTDB" cannot reach
- Specified stop point (end-of-log or point-in-time) on database partition (s)
- "0". Roll-forward recovery processing has halted on log file "S0000005.LOG ".
At this time, the database is still in pending state. If you execute db2 rollforward db testdb stop again, the DB2 backup can be restored to the State before the database is deleted.