DB2 Redirect Restore
Well we all are familiar that a database restore operation uses a database backup image to recreate a database. We can perform a redirected restore operation in any of the following situations:
If you want to restore a backup image to a target machine that is different from the source machine
If you want to restore your table space containers into a different physical location
If your restore operation failed because one or more containers are inaccessible
If you want to redefine the paths of a defined storage group
Note: You cannot use a redirected restore to move data from one operating system to another. You cannot create or drop a storage group during the restore process. You cannot modify storage group paths during a table space restore process even if you are restoring all table spaces that are associated with the storage group.
In this Blogpost we will see and learn "How to relocate an existing DB2 database?" And, to do this we have two methods:
Take a backup and restore with a DB2 Redirect Restore
Or, Use db2relocatedb
But I prefer the first method coz DB2 Redirect Restore forces the DBA to take more precautionary steps.
One main thing about the Redirect Restore operation is that it will generate the script and we only have to do few modifications in that script and post modifications execute the script to complete the db2 redirect restore. Although db2relocatedb should follow the same levels of caution such as backups and I'll discuss this second method in another Blogpost.
Scenario : Lets assume you have a database on a path “/db2inst/dbdata1/” and would like to move the database to new path “/db2inst/dbdata2/”. Now using the "DB2 Redirect Restore" method we will follow the below steps:
Step 1 : Take VM backup of your server (Or ask your OS team to take and save VM Snapshot at their end so that we can use this in case of rollback).
Step 2 : Take and make sure that all databases and relevant database server files are backed up (Tape backup is recommended).
Step 2 : That particular database for which DB2 Redirect Restore will be performed : Ensure a FULL BACKUP is available and the FULL BACKUP was completed by Db2 Storage/Backup facility/Team.
Step 3 : Inform about this activity to all the concern team in advance so that availability of server and network will be made sure. Check that you can connect to the database or not. If crash recovery is required complete it first.
Step 4 : Is the database on multiple partitions and no target database exists – then the script must be executed partitions by partition. I will prefer you to create a target dummy database which runs the script over all the partitions.
Step 5 : Command to create and generate DB2 Redirect Restore script.
db2 restore db jc66db from /db2inst/backups taken at 20210926117240 redirect generate script jc66db.clp
Step 6 : Open the generated DB2 Redirect Restore script in a text editor to make any modifications necessary.
Details to modify are :
Login details : username\password
Restore options : ON,DBPATH ON, INTO,NEWLOGPATH etc
Automatic storage paths
Container layout and paths
For example:
ON : Indicates the file system where the database will be created
NEWLOGPATH : Indicates the log files location to be used for the new database
Step 6 : Execute the script
db2 -tvf jc66db.clp
Step 7 : Confirm directory details
db2 list db directory
db2 list db directory on /home/db2inst/
That's all in this post. If you liked this blog and interested in knowing more about IBM Db2. Please Like, Follow, Share & Subscribe to www.ImJhaChandan.com.
Comments