I’ve upgraded my employer’s Lab Manager installation to 4.0.1 last thursday. I followed procedure by disallowing new deployments, undeploying all virtual machines, making sure nobody could login, double-decked that no event were currently running and make backups of the virtual machine and database files.

I commenced the upgrade, and clicked through the installer. The upgrade went smooth as far as I could see. After the upgrade, I went to the webpage of the LM-server to finish the upgrade wizard. Instead of the upgrade wizard, I was welcomed by the initialization wizard. It scared the hell out of me, this was not supposed to happen!

I assumed the installer did a boo-boo with the database, replacing it with a fresh one instead of upgrading the old one. I was right, in the installation directory of SQL I found the ‘old’ database in a *.renamed format. The new database files were smaller and had newer modified dates.

To restore the database, I had to do the following:

  • Stop the HTTP SSL, IIS Admin Service, World Wide Web Publishing Service, VMware vCenter Lab Manager Monitor and VMware vCenter Lab Manager SupportLink services.
  • Make sure that the ‘SQL Server (LABMANAGER)’ service is running.
  • Restore the database using osql.
  • Restored user rights to the LabManager database using osql.
  • Restarted the above services (including the SQL Server).

I used osql for all the database interaction. You can use Microsoft SQL Server Management Studio Express as well.

Restore the database:

OSQL -S localhostlabmanager -E -Q "restore database labmanager
 FROM DISK='c:\lm_backup.bak' with replace"

Restore the user rights to the database:
osql -S localhostLabManager -E
USE [LabManager]
USE [LabManager]
EXEC sp_addrolemember N'db_datareader', N'LABVMwareLMClientAccts'
EXEC sp_change_users_login 'auto_fix','LABVMwareLMClientAccts'

For future reference: backups of the database are made using this command:
OSQL -S localhostLabManager -E -Q "backup database labmanager
 TO DISK='c:\lm_backup.bak'"