Wednesday, December 29, 2010

How to recover DB2 Database using ROLLFORWARD command

In earlier article i explained about restore command. How can we use restore command to recover db2 database.

There is another command ie ROLLFORWARD, by which you can also recover your DB2 database but this command used in some special cases like:

If you perform a change to the database after you backed it up? Are the inserts or changes you made to rows lost?

In this case we used rollforward command. It lets you recover changes to your databases from transaction logs that DB2 maintains behind the scenes.

We can use this command:

1. through the command line processor (CLP).
2. the database Rollforward Wizard in the Control Center.
3. or the db2Rollforward API.

To test out how rolling forward works, add a new row to the database table:

db2 => insert into secretidentities values (Jack, Ketty)

If you restored your database from the image you created earlier, you would not be able to see the row insert above.
You can perform a rollforward using the following syntax:

db2=> rollforward database backdem user db2admin using db2admin
to end of logs and stop

Some important points you have to remember when using rollforward command:

  • Rollforward command also have one advantage that is you have no need to connected to the database that is to be rollforward recovered: The rollforward utility automatically establishes a connection to the specified database, and this connection is terminated at the completion of the rollforward operation.
  • You can invoke only one rollforward operation at a time.
  • If you have renamed a table space following the most recent backup operation, ensure that you use the new name when rolling the table space forward. The previous table space name will not be recognized.
  • You cannot cancel a rollforward operation that is running.
These are some important & basic points that I mentioned here but in some cases this command does not work properly because this command has its own limitations. At this time we have another option to recover our db2 database ie DB2 Recovery Software. DB2 Database Recovery Software recover db2 database in most possible causes of corruption.

No comments:

Post a Comment