Personal tools
You are here: Home DB2 How To's Using RECOVER command inspite of RESTORE and ROLLFORWARD command
Navigation
Log in


Forgot your password?
 
Document Actions

Using RECOVER command inspite of RESTORE and ROLLFORWARD command

Simplified Restore and Rollforward Command

For those that have been using DB2 for some time or those coming from other data servers, you are likely familiar with the RESTORE command. With RESTORE, you specify the backup image you want to restore (indicated by the timestamp the backup was TAKEN AT) the media you are restoring from and 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.

What many may not be aware of is that in V8 there was a simplification of this process. The RECOVER command not only combines the above two steps into a single step but it also focuses on what you want to accomplish rather than how to accomplish that task. What I mean by this is you simply specify at what point in time you want the database to be at after the recovery and DB2 figures out the best way to get you there.

For example if you simply want to get the database back to the end of the log files that exist you simply run

db2 RECOVER DATABASE db_name TO END OF LOGS


db2 RECOVER DATABASE sample to end of logs

    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                    = S0000002.LOG - S0000011.LOG
 Last committed transaction             = 2008-04-22-13.14.25.000000

DB20000I  The RECOVER DATABASE command completed successfully.


That's all you need to do. DB2 will look at the recovery  history file for the database name specified, find out where the most recent backup has been written to (Disk, TSM, other vendor backup management software, etc) and then automatically invoke the restore command with the proper parameters for the time taken and source media. Then when the restore completes it automatically invokes the roll forward command to take you to the end of logs. At a time when you need to perform a recovery of the database, that's typically not the time when you want to have to deal with any added complexity so simplification of recovery processing sure is a nice thing.

Some other nice features with the RECOVER command:

  • You can use it in a DPF environment and it will automatically find the correct backup images for each database partition and perform the restore on all nodes for you. Or you can also specify ON which database partitions you want recovery to occur.
  • If you specify a point in time for the recovery (i.e. TO 2007-10-31-18.00.00 rather than TO END OF LOGS) then the default is to use your local time rather than UTC so it's typically more user friendly.
  • If you specify a point in time to recover to, DB2 will find the backup image closest to (but before) that point in time to use for recovery
  • If you have full and incremental backups, DB2 will find the most efficient way to perform the recovery for you using the combination of incrementals that makes the most sense.
  • The RECOVER command can take as input USE HISTORY FILE path_to_history_file so that you can automate the recovery to a new server


Source: ITtoolbox Blogs

Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls