Monday, January 3, 2011

How to recover DB2 Database using RECOVER command

After describing restore & rollforward command now I am going to explain one another command which is in-Built Command in db2 database ie RECOVER command to recover corrupted DB2 database.

Why am I explaining this command after restore and roll forward commands, there is one major reason behind this ie RECOVER Command is the combination of restore and rollforward commands.

As i explained in earlier article that In RESTORE command, you have to specify the backup image that you want to restore, timestamp the backup was, the media you are restoring from and also the database name you are restoring to.

Then if you want to roll the database forward to end of logs or a point in time you follow the restore with a ROLLFORWARD command.

The RECOVER command combines the above two steps of restore & rollforward commands into a single step & also focuses on what you want to accomplish rather than how to accomplish that task.

How to use this command:

RECOVER DATABASE db_name TO point_in_time

Advantages of Recover Command:

1) You don't need to tell it where to get the backup image from. It will automatically look in the recovery history file to find out what is the best backup image to use in order to get to the point in time you specify.

2) You can also give it a different recovery history file on disk if the database does not yet exist. This can greatly simplify a restore operation and when you need to do a restore is when you need things to be simple.

3) One major advantage of RECOVER command is that the it can be restarted if it fails and pick up from where it left off.

Some points to remember when using Recover Command:

  • A database connection is required when you recover an existing database.
  • This command automatically establishes a connection to the specified database and will release the connection when the recover operation finishes.
  • If you want to recover a new database than an instance attachment and a database connection are required. The instance attachment is required to create the database.
But in most of the cases this command fails to recover corrupted db2 database. In this case you can try DB2 Recovery Software to recover your corrupted db2 database.

No comments:

Post a Comment