When Macrium Reflect takes an image, it invokes Volume Shadow Copy Service (VSS). This is a Microsoft component that takes a point-in-time snapshot. This snapshot remains active until the imaging completes. This creates a backup that results in a consistent restore .
SQL Server is a VSS aware application. If you receive VSS errors related to SQL that you are unable to resolve you can create batch files for Macrium Reflect to run at the beginning and end of the snapshot that automatically stop then start the MS SQL service.
Security Warning
This functionality is 'Off' by default and can be turned 'On' by creating the following registry entry:
Key: | HKEY_LOCAL_MACHINE\SOFTWARE\Macrium\Reflect\settings |
Name: | EnablePrePostScripts |
Type: | DWORD32 |
Value: | Off = 0, On = 1 |
Default: | 0 |
To prevent unauthorised creation and modification of the batch files described in this article please see Macrium Reflect and best practices for file security
To disable the SQL server service for the duration of the snapshot:
- Find the name of the SQL Service that you want to stop:
Start the Microsoft Service manager by running 'services.msc'
Open the properties for the service and copy the service name:
In this case the service name is: MSSQL$SQLEXPRESS - Create batch files in the same folder as the XML definition file.
You can type batch files as text using a program like Notepad before saving them with a .bat file extension. To determine the XML definition file folder, select the XML definition file and click Open the containing folder in Windows Explorer button on the toolbar.
Format the names of the batch files so Macrium Reflect automatically uses them for the XML definition. The batch files should be named as below:
<definition file name>_before_snapshot_wait.bat
<definition file name>_after_snapshot.bat
Replace
<definition file name>
to be the same name as the definition file. For example, if you have a definition file with the name:My SQL Backup.xml
then the above two batch files will be named:
My SQL Backup_before_snapshot_wait.bat My SQL Backup_after_snapshot.bat
Note: The
wait
part of the file name causes Macrium Reflect to wait until the batch file returns before continuing with the volume snapshot. This is recommended when backing up SQL Server to ensure that the database is in a closed state.The content of the
_before_
snapshot batch file should be:NET STOP MSSQL$SQLEXPRESS
Note: Replace MSSQL$SQLEXPRESS with the name of your SQL service
The content of the
_after
_snapshot batch file should be:NET START MSSQL$SQLEXPRESS
Note: Replace MSSQL$SQLEXPRESS with the name of your SQL service
When the backup definition is executed the SQL Service stops just before to Macrium Reflect creates the volume snapshot then starts again a few seconds later after the snapshot is created.