Backup and recovery data database Case 2-use online backup to restore the database.
1. Set archiving Parameters
1,
Drop database mydb
Create Database mydb
Update dB CFG for mydb using implements logpathd: \ backup \ log
2. updatedb CFG for using userexit on // Enable User exit
3. db2update dB CFG for using logretain on // enable archiving logs
4. db2update dB CFG for using trackmod on // enable the Incremental backup function
DB2 => List applications
Authorization identity Application name application identity database proxy
Program
Handle name no.
-----------------------------------------------------------------------------
------------------------------
Db2admindb2bp.exe 907 * local. db2.110925011911
Mydb 1
Db2adminjavaw.exe 946 * local. db2.110925013547
Mydb 1
Db2adminjavaw.exe 945 * local. db2.110925013541
Mydb 1
DB2 => force application all
The db20000i Force Application Command is successfully completed.
Db21024i this command is asynchronous and may not take effect immediately.
DB2 => List applications
Sql1611w "database system monitor" does not return any data.
DB2 => connect to mydb
Database connection information
Database Server = DB2/nt64 9.7.4
SQL authorization id = db2admin
Local Database alias = mydb
Ii. Back up online databases
1. DB2 backup database mydbto D: \ backup # online backup
DB2 => backup database mydb online TODD: \ backup
The backup is successful. The time stamp of this backup image is: 20110925094833
2. Create a table to simulate disaster recovery
DB2 => Create Table Test (idvarchar (10 ))
The db20000i SQL command is successfully completed.
DB2 => insert into test values ('1 ')
The db20000i SQL command is successfully completed.
DB2 => commit work
The db20000i SQL command is successfully completed.
DB2 => select * from test
ID
----------
1
1 record selected.
3. Perform Incremental Backup online. # note that the table definition and data are in this Incremental backup.
DB2 => backup database mydb incrementalto D: \ backup
The sql1035n database is currently in use. Sqlstate = 57019
DB2 => List active databases
Activity database
Database Name = mydb
Currently Connected Application = 1
Database Path = D: \ DB2 \ node0000 \ sql00005 \
DB2 => force application stop
Sql00000n finds the exception mark "stop" after "application ". The expected tags may include: "All ".
Sqlstate = 42601
DB2 => force application all
The db20000i Force Application Command is successfully completed.
Db21024i this command is asynchronous and may not take effect immediately.
DB2 => backup database mydb incrementalto D: \ backup
The backup is successful. The time stamp of this backup image is: 20110925104257
4. DB2 list history backupall for mydb // view backup records
3. simulate a disaster
1. # Drop the database to simulate disaster recovery
DB2 => drop dB mydb
The db20000i drop database Command is successfully completed.
DB2 => connect to mydb
Sql1013n cannot find the database alias or database name "mydb ". Sqlstate = 42705
4. Restore the database
DB2 => restore dB mydb incrementalautomatic from D: \ backup taken at 20110925104257
The db20000i Restore database command is successfully completed.
DB2 =>
DB2 => connect to mydb
Database connection information
Database Server = DB2/nt64 9.7.4
SQL authorization id = db2admin
Local Database alias = mydb
DB2 => select * from test
ID
----------
1
1 record selected.