Db2

Db2

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
  • 1.  Restoring an online database backup without logs or corrupted logs.

    Posted Wed September 25, 2024 10:01 AM

    Hi Guys,

    I am testing a scenario where I can restore an online database backup without any archived logs in a test environment. Is there any way to restore the backup image. It is okay if the last uncommitted transactions are not restored. I tried every option on restore command and roll forward command. I even tried to recreate an empty log file and put it into the log overflow path without any success.

    Thanks!

    Sahan



    ------------------------------
    Sahan Mendis
    ------------------------------


  • 2.  RE: Restoring an online database backup without logs or corrupted logs.

    Posted Wed September 25, 2024 10:33 AM

    Hi Sahan,

    If you are sure that the online backup is consistent (online backup should include logs required for restore), this should work:

    #Example of online backup

    db2 backup db testdb online to "/db2/backup" include logs

    #For eg. create overflow dir (or use any other):

    mkdir -p /db2/logs_tmp

    #Restore

    db2 restore db testdb from '/db2/backup' taken at 20240906225454 into testdb1 logtarget '/db2/logs_tmp'

    #Check rollforward status:

    db2 rollforward db testdb1 query status

    #Finish rollforward using logs from backup:

    db2 "rollforward db testdb1 to end of backup and stop overflow log path (/db2/logs_tmp)"

    #Activate db and test

    db2 activate db testdb1

    BR,

    Ivan



    ------------------------------
    Ivan Milojevic
    Belgrade
    ------------------------------



  • 3.  RE: Restoring an online database backup without logs or corrupted logs.

    Posted Thu September 26, 2024 09:10 AM

    Ivan is correct. Make sure you include the logs in the online backup. If you lose the logs not in the backup, you can still bring the database online, you just cannot roll it forward.

    Years ago (early 2000's) I had an issue where I had to restore a backup and the logs were missing. There was nothing I could do to bypass the issue and bring the database online - other than calling IBM. Back then they had a 1-time, customized script you could run that would reset the log pointers and bring the database back online. Don't know if they still provide that service though.



    ------------------------------
    Douglas Kostelnik
    ------------------------------



  • 4.  RE: Restoring an online database backup without logs or corrupted logs.

    Posted Thu September 26, 2024 05:05 PM

    Hi Salan,

    I'm typing this on a long haul flight, so won't provide any links. However here are some pointers...

    • You always need logs to restore from online backup.
    • However, by default (except for DPF databases and I am not sure about pureScale) Db2 backups include a minimum set of logs sufficient to restore then rollforward to END OF BACKUP.
    • You need to extract those logs from the backup image. This can be done using the RESTORE DATABASE command to restore the database with the LOGTARGET clause to extract the embedded logs to a directory.
    • You can then use the ROLLFORWARD command to rollforward the database to END OF BACKUP and STOP.

    Please read the online manuals for more details. If this is important, suggest you practice before doing for real.

    To rollforward beyond the end of backup, you would need subsequent logs, but the backup does not include those of course.

    Good luck!

    Jeremy Rickard 



    ------------------------------
    Jeremy Rickard
    ------------------------------