Backup VMware SQL 2005 Express Databases

By | October 1, 2008

I just upgraded our systems with VMware's ESX server.
When installing you can use SQL 2005 Express, but the downfall is that there isn't an automated backup in the management studio.
So I created a batch file that would call a SQL query.

 

 

 

 

This is the first SQL Query "Save as sqlbackup1.sql"
———-COPY EVERYTHING BELOW THIS LINE———-
BACKUP DATABASE [VIM_UMDB] TO  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\VIM_UMDB.bak' WITH NOFORMAT, NOINIT,  NAME = N'VIM_UMDB-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
———-COPY EVERYTHING ABOVE THIS LINE———-

 

This is the second SQL Query "Save as sqlbackup2.sql"
———-COPY EVERYTHING BELOW THIS LINE———-
BACKUP DATABASE [VIM_VCDB] TO  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\VIM_VCDB.bak' WITH NOFORMAT, NOINIT,  NAME = N'VIM_VCDB-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
———-COPY EVERYTHING ABOVE THIS LINE———-

 

This is the batch file you can schedule to run.
———-COPY EVERYTHING BELOW THIS LINE———-
sqlcmd -S.\SQLEXP_VIM -i"C:\Scripts\sqlbackup1.sql"
sqlcmd -S.\SQLEXP_VIM -i"C:\Scripts\sqlbackup2.sql"
 
———-COPY EVERYTHING ABOVE THIS LINE———-
 

***MAKE SURE NO WORD WRAP IS HAPPENING IN YOUR SCRIPT

 

1. The SQL query will backup the databases to "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\"          
2. Place the .sql file into a directory called "C:\Scripts\"

This information is provided "AS IS" with no warranties expressed or implied.

 

Leave a Reply

Your email address will not be published. Required fields are marked *