Search code examples
db2windows-10database-restoredb2-luwdb2-express-c

DB2 restore command fails on Windows 10


Installed DB2 Express C v10.5 and also v11.1 on Windows 10 PC.

Database backup is successful but Restore ends with error with both versions.

I also tried the same using Data Studio 4.1.2, but here also backup is successful but restore command is stuck.

Backup and restore script from Data Studio-

CONNECT TO SAMPLEDB;
QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS;
CONNECT RESET;
DEACTIVATE DATABASE SAMPLEDB;
BACKUP DATABASE SAMPLEDB TO "E:\Database" COMPRESS EXCLUDE LOGS WITHOUT PROMPTING;
CONNECT TO SAMPLEDB ;
UNQUIESCE DATABASE;
CONNECT RESET;

RESTORE DATABASE SAMPLEDB FROM "E:\Database" TAKEN AT 20161020191200 INTO NEWDB WITHOUT PROMPTING;

This works fine on Windows 7 and 8.

Is this problem specific to Db2 Express C on Windows 10? Can anyone suggest solution and/or where to read about the compatibilty status.

Added-

Restore from Data studio does not give any error, but is just stuck.

Result of backup and restore script-

db2 => CONNECT TO CBL2010 USER db2admin USING *******

   Database Connection Information

 Database server        = DB2/NT 10.5.5
 SQL authorization ID   = DB2ADMIN
 Local database alias   = CBL2010

db2 => QUIESCE DATABASE IMMEDIATE
DB20000I  The QUIESCE DATABASE command completed successfully.

db2 => CONNECT RESET
DB20000I  The SQL command completed successfully.

db2 => BACKUP DB CBL2010 USER db2admin USING ******* to E:\Backup COMPRESS WITHOUT PROMPTING

Backup successful. The timestamp for this backup image is : 20161024162942

db2 => CONNECT TO CBL2010 USER db2admin USING *******

   Database Connection Information

 Database server        = DB2/NT 10.5.5
 SQL authorization ID   = DB2ADMIN
 Local database alias   = CBL2010

db2 => UNQUIESCE DATABASE
DB20000I  The UNQUIESCE DATABASE command completed successfully.

db2 => CONNECT RESET
DB20000I  The SQL command completed successfully.

db2 => RESTORE DB CBL2010 USER db2admin USING ******* FROM E:\Backup TAKEN AT 20161024162942 INTO CBLBKUP WITHOUT PROMPTING
SQL1092N  The requested command or operation failed because the user ID does
not have the authority to perform the requested command or operation.  User
ID: "XAXTRANET".  SQLSTATE=00000

Here, I am supplying 'db2admin' as the user, but surprisingly the error is for the logged in user 'XAXTRANET'.

Both logged in and supplied user have PC admin rights.

and as per 'get Dbm Cfg' command, the sysadm group is not set -

 SYSADM group name                        (SYSADM_GROUP) =
 SYSCTRL group name                      (SYSCTRL_GROUP) =
 SYSMAINT group name                    (SYSMAINT_GROUP) =
 SYSMON group name                        (SYSMON_GROUP) =

Solution

  • The authorization ID you are specifying as part of the command (RESTORE ... USER db2admin ...) is used to connect to an existing database. Since you seem to be restoring to a new database (...INTO CBLBKUP...), that database has to be created first, which requires an instance attachment, this is where the ID XAXTRANET is coming from.

    Try attaching to the instance explicitly before issuing the RESTORE command:

    db2 => ATTACH TO DB2 USER db2admin USING whatever
    

    The above assumes you are using the default instance name DB2 -- change it to your actual instance name if needed.