Pages

Wednesday, 20 December 2017

IBM Maximo DB2 Database - How to perform an online backup / restore

When your DB2 database is running in an ONLINE mode. the system starts producing archive logs.

In order to restore this database to another database, your original backup should contain these log files to roll forward the database to end of logs and complete.

Backup :

Issue Following Command :


-- Connect to the database console
db2cmd
-- Set the current instance
set DB2INSTANCE=DB2
-- Issue backup command
backup db maxdb76 online TO "C:\Command" COMPRESS INCLUDE LOGS

Restore :


Create a folder called Command under your system root (C:\Command)

Copy the database backup file to this folder

Open CMD and change directory to C:\Command by issuing cd C:\Command

Now follow the below script :


-- Connect to the database console
db2cmd
-- Set the current instance
set DB2INSTANCE=DB2
--Make sure all connections are closed (Maximo stopped)
--Stop the database
db2stop force
--Start the database
db2start
-- Issue this command to generate the db.txt script
-- 20161114160751 is the rowstamp of your database, take it from the database backup name
db2 restore db maxdb76 from C:\Command taken at 20161114160751 redirect generate script db.txt
-- Open db.txt for edit
-- Change LOGTARGET by specifying the folder where to extract the log from the backup
-- unckech and put the correct system root SET STOGROUP PATHS FOR IBMSTOGROUP ON 'C:'
-- Specify the target database in INTO parameter
-- Save the file then issue the command
db2 -tvf db.txt
-- After restore completed , now run the rollforward the database
-- c:\LOG specified in log target of the command db2 restore
db2 rollforward db maxdev to end of logs and complete overflow log path ("c:\LOG")
-- Now try to connect to the database, it should work
db2 connect to maxdb76



0 comments:

Post a Comment