Child pages
  • Stopping a SQL Server service automatically when backing up
Skip to end of metadata
Go to start of metadata

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.

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

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:

      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:

      Note: Replace  MSSQL$SQLEXPRESS with the name of your SQL service

    • The content of the _after_snapshot batch file should be:

      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.