How to perform a db2 redirected restore

Sometimes you need to restore db2 databases on a different machine. For example during on prem to cloud migrations, or when moving database servers during an upgrade for Connections. In most cases some of the paths will be different. The LOGPATH is gonna be your main issue. Goal of this post is to show you how to restore the database and change the LOGPATH setting inside the database you are restoring on the fly. Once you get the hang of it, explore the response file for other parameters you can change. I am assuming you have already transferred the backup image to the new server.

Run the following command on the target to generate a response file for the restore

db2 restore db blogs from /backups redirect generate script /tmp/blogs.clp

Inside the file change the following parameters

    ON '/data/db2inst1'
    LOGTARGET 'tmp'
    NEWLOGPATH '/data/db2/logs/blogs'

    Where ON represents your db2 default database path. To see what this is on your new instance run the following as the db2 instance user

    db2 get dbm cfg |grep DFTDBPATH

    The LOGTARGET is a temp space you need to perform the restore, it’s where the included log files from the backup go until you roll the database forward

    The NEWLOGPATH is where you want all active logs to go

    Once the file has been changed and saved run the following to run the restore, rollforward to the latest log files available and check the rollforward status

    db2 -tvf blogs.clp
    db2 "rollforward db blogs to end of logs and complete overflow log path ('/tmp')"
    db2 rollforward db blogs query status

    The Rollforward status should be “not pending’

    Leave a Reply

    Your email address will not be published. Required fields are marked *