Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 7

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.

Info
Note: You can also use the similar batch files to stop and start other services, such as MySQL that are not VSS aware.


Warning
titleSecurity 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:

  1. 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

  2. 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.

  3. 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. 

     


  4. 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:
       

      Code Block
      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:

      Code Block
       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:

      Code Block
      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.