Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2007
    Posts
    288

    Unanswered: 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??

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    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.

  3. #3
    Join Date
    Dec 2007
    Posts
    288
    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 11:41.

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  5. #5
    Join Date
    Dec 2007
    Posts
    288
    I didn't try that!!! I'll give it a try! Thanks so much

  6. #6
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •