KCF Technologies Help Center

Follow

How to Backup and Restore VMS Database

This article is helpful for anybody that needs to keep backups of their VMS data.

Pre-requisites

You will need to be logged into your Windows machine as an administrator.

Before getting started you will need to create a folder for the following files:

VMSBackup.bat

SQLExpressBackups.sql

VMSRestore.bat

SQLExpressRestore.sql

Backup The Existing Database

  1. Edit the SQLExpressBackups.sql file for your computer. If you look at the file you can see that I placed everything in a folder named "DBbackups", and named my backup file VMSz.bak. So make sure to have the correct file and path names here. If you are making regular daily or weekly backups of the system you might want to name the backup using the date, so something like vms04162014.bak to represent April 16, 2014. The file name will need to be adjusted each time you backup if you would like to keep each backup unique.

    BACKUP DATABASE [VMS]
    TO  DISK = N'C:\DBbackups\VMSz.bak'
    WITH NOFORMAT, NOINIT,  NAME = N'VMS-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
    GO
  2. Edit the VMSBackup.bat file for your computer. The parts you will need to adjust are the files and paths. So I have a file in my C drive named "dbbackups" that has the file SQLExpressBackups.sql in it. Make sure the filepath exists to "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE". If it doesn't exist then look through the filesystem to find the SQLCMD.exe file.

    "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" -S localhost\VMS -U vmsuser -P vms -i C:\dbbackups\SQLExpressBackups.sql
  3. Double-click the VMSBackup.bat file to run the backup. If you want to make sure the process completes without errors, open a command prompt, copy the contents of VMSBackup.bat into the window, and hit enter.
  4. You should see the file in your directory now. I can now see a file named VMSz.bak in my directory. It is best to store this file on a drive other than the one holding the SQL Database so that it can be restored in the event of a crash.

Restore From Backup File

  1. Install VMS
  2. Open the localhost database in VMS to make sure you can connect to it and that it is blank. If the VMS Viewer opens the localhost data without an error, and everything is blank then it is working.
  3. Edit VMSRestore.bat to fit your filesystem. Make sure the SQLCMD.exe file exists in the file location in this file (see also step 2 in the Backup instructions). 

    "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" -S localhost\VMS -i C:\dbbackups\SQLExpressRestore.sql
  4. Edit the SQLExpressRestore.sql file to match your filesystem (edit the path to the file on the line that says "FROM DISK...):

    RESTORE DATABASE [VMS]
    FROM DISK = N'C:\DBbackups\VMSz.bak'
    WITH FILE = 1
    NOUNLOAD, 
    REPLACE, 
    STATS = 10
    GO
    USE [VMS]
    GO
    /****** Object: User [vmsuser] Script Date: 07/19/2011 15:29:22 ******/
    if NOT EXISTS (Select * from sys.database_principals Where name = N'vmsuser')
    Begin
    CREATE USER [vmsuser] FOR LOGIN [vmsuser] WITH DEFAULT_SCHEMA=[dbo]
    End
    GO
    EXEC sp_addrolemember N'db_owner', N'vmsuser'
    GO
    EXEC sp_change_users_login 'Auto_Fix', 'vmsuser'
    GO
  5. Stop the "VMS Data Service" and "VMS Collection Server" services. Make sure the VMS Viewer and VMS Configurator are also closed. (To do this click the windows 7 start button, type "services", and click on the button named "Services" or "View Local Services"). Click the services in the list, then click Stop. 
  6. Double-click the file labeled VMSRestore.bat to run the restore process. If you want to make sure the process completes without errors, open a command prompt, copy the contents of VMSRestore.bat into the window, and hit enter.
  7. The data should be restored. To use VMS again you will need to restart the two services or reboot your computer
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk