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 > Automatic restore

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-15-09, 09:50
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
Automatic restore

DB2 9.5 on Windows. I periodically restore our Production Datamart Database to a Development area and now I would like ot do this on a scheduled (once a week basis) and automate it. My problem is trying to firgure out how to do the restore when the backup filename changes everytime??? I was planning on using the task center and scheduling a one-off backup that I would use for my restore.. BUt I'm not sure how to write the restore command since the backup filename changes everytime/??? anyone have any ideas??
Reply With Quote
  #2 (permalink)  
Old 01-15-09, 10:11
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
You do not need to know the backup file name - only the time of the backup. This can be obtained from the output of list history command or the db_history administrative view.

If you have only one backup on a specific date, db2 will be able to find the backup for you even if you specify only the date in the TAKEN AT part of the command.

Not sure about your requirements, but you may be able to use RECOVER database command.

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 01-15-09, 10:36
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
so if I only need to know the backup time.. how would I code that in the recover or backup command..

db2 restore db sample from D:\DB2Backups taken at 20010320122644 would be my command.. but the 'taken at 2001.....' would change every week...

need to scheduled it so that it runs in the wee hours of the morning once a week?

Last edited by itsonlyme44; 01-15-09 at 10:41.
Reply With Quote
  #4 (permalink)  
Old 01-15-09, 10:50
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If you create a separate directory which only contains one backup file for a particular database, you can omit the "taken at" clause. I have done this by using a script that always moves the existing backup to an archive backup directory right before taking the latest backup, so that my directory only contains one backup per database, and then I can automate the restore.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 01-15-09, 10:53
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
I didn't try that!!! I'll give it a try! Thanks so much
Reply With Quote
  #6 (permalink)  
Old 01-15-09, 11:54
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
You can obtain the backup timestamp using db_history admin view ... of course, it needs OS Scripting. Marcus suggestion will make it straight forward.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
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