This week I did something that I found wasn’t very well documented. I was to move a few DB2 databases from one server installation to another one and also from an older version of DB2 to a newer one.

The process should be simple but as with most technologies it wasn’t quite as simple. My initial idea was to use online backups to not have any downtime but i wasn’t able to do that. For me i wasn`t able to restore the online backups om a newer version.

Instead I went with the route of doing offline backups and restores. Another issue in my setup was that I had different disk setup between the servers. So how did I do this? I shutdown the applications that was connected to the databases and then i did these steps on the source server:

db2 connect to WPSDB
db2 quiesce database immediate force connections
db2 connect reset
db2 deactivate db WPSDB

db2 backup db WPSDB to e:\db2backups compress

db2 activate db WPSDB
db2 connect to WPSDB

db2 unquiesce database
db2 connect reset

The above will do an offline backup and write it to the selected path. Next step is to restore the database on the destination server. I copied the database file to a destinstion path and opened a db2 cli window on the destination server. And ran these commands:

db2 restore db WPSDB from d:\db2backups taken at 20200415140318 on d:\ dbpath on d:\DB2\NODE0000\WPSDB into WPSDB replace existing redirect

db2 restore db WPSDB continue

db2 update db cfg for WPSDB using logarchmeth1 DISK:D:\DB2LOGS\WPSDB

What is import with the restore command is to specify the correct parh to the db2 database as well as the root path för the db2 instance. Also after restore db .. continue you need to change the path for the archives logs as the restore will set the path from the source server.

Now everything should have worked and your database is available on the new server. The exemples above is for Windows based environments but to do the same in linux you should only need to specify other patha.

I hope you as a reader will find this useful if you are like me a db2admin as part of many other roles.