Link to home
Start Free TrialLog in
Avatar of Jim Youmans
Jim YoumansFlag for United States of America

asked on

DB2 Restore to different database name on same server

DB2 10.5 on Windows

I want to restore my test database on a windows server to test2 database on the same server but I am a bit confused by the RESTORE WITH REDIRECT method.

So the test database is on the D: drive and I want to put the test2 database on the Z: drive.  I ran the RESTORE ... REDIRECT GENERATE SCRIPT so I have a script to work with.  The script has all the tablespaces for the test db in it but it is all commented out.  Like this.

-- *****************************************************************************
-- ** Tablespace name                                  = SYSCATSPACE
-- **   Tablespace ID                                      = 0
-- **   Tablespace Type                                 = Database managed space                      
-- **   Tablespace Content Type                  = All permanent data. Regular table space.    
-- **   Tablespace Page size (bytes)            = 4096
-- **   Tablespace Extent size (pages)        = 4
-- **   Using automatic storage                  = Yes    
-- **   Storage group ID                                = 0
-- **   Source storage group ID                   = -1
-- **   Data tag                                                = None
-- **   Auto-resize enabled                           = Yes    
-- **   Total number of pages                      = 501844
-- **   Number of usable pages                   = 501840
-- **   High water mark (pages)                   = 113376
-- *****************************************************************************

Do I need to create these tablespaces before I do the restore or will the restore command automatically create them on the new drive?

Same question with log files.  Here is what the restore script currently has.

INTO test
-- LOGTARGET '<directory>'
-- NEWLOGPATH 'L:\db2logs\test\NODE0000\LOGSTREAM0000\'

I know I need to change the INTO command to INTO test2 and L: is the current log file path for Test and I want to change it to the new drive (Z:) but do I have to create the directory first or will the restore do it?

I appreciate any and all help.

Thanks!!!

Jim
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Hi Jim,

The IBM docs have a pretty good description of the process:

  https://www.ibm.com/support/knowledgecenter/en/SSEPGG_10.5.0/com.ibm.db2.luw.admin.ha.doc/doc/c0006249.html

In a nutshell, you can put the database on any device or file system with the SET TABLESPACE CONTAINERS command:

  https://www.ibm.com/support/knowledgecenter/en/SSEPGG_10.5.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0002009.html


Kent
Avatar of Jim Youmans

ASKER

So if I have 20 tablespaces, I would need to define them all via the SET TABLESPACE CONTAINERS?
ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial