If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Restore latest backup

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-27-10, 15:27
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
Restore latest backup

Linux RHEL 5.5 - DB2 V8.2 FP14

I am trying to automate a process that needs to restore the production database from the latest backup that is in a directory with previous backups. There is more that 1 backup file in the directory for the same database but I want to restore the latest.

Is there a DB2 command to do this ?

Thanks
Reply With Quote
  #2 (permalink)  
Old 08-27-10, 15:34
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
There is no such command, but you can find the latest backup timestamp by selecting from the table function ADMIN_LIST_HIST(), then use the timestamp to invoke RESTORE with the TAKEN AT clause.
Reply With Quote
  #3 (permalink)  
Old 08-27-10, 16:00
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
Thanks for the suggestion. I got the taken at value but having problems placing in the restore command.................
Reply With Quote
  #4 (permalink)  
Old 08-30-10, 14:50
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
Got it...................

db2 -x "select 'db2 restore db TESTDB from /home/db2server01/backup/ taken at', (SELECT START_TIME FROM TABLE(SYSPROC.ADMIN_LIST_HIST()) AS backup_time where OPERATION='B' Order by START_TIME desc fetch first 1 rows only), 'replace existing;' FROM SYSIBM.SYSDUMMY1"

Last edited by mdx34; 08-30-10 at 15:31.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On