@TonyCzar,
Here are my notes on excluding folders from a VSS snapshot that I referenced earlier along with a sample batch file:
---------------
To prevent specific folders from being snapshotted by VSS, which in turn prevents them from being backed up by an image backup, navigate to this location in the registry with regedit.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot\
Add a new
Multi-String Value
:
Value Name :
Volume Shadow Copy Data
Value Data :
C:\Virtual Machines\*.* /S
The example above excludes
C:\Virtual Machines
from being snapshotted along with all files and subfolders.
IMPORTANT: You MUST always include an entry for
$AllVolumes$\System Volume Information\*.* /s
to prevent the snapshots themselves from being backed up, resulting in very large backups.
NOTE: Add one entry per line for the value and do not enclose the path in quotes even if the path has spaces in the name.
To do this from the command, use the command below as an example.
NOTE: Do this from an elevated command prompt or a batch file run elevated. If you need to add multiple lines, separate each line item with a
\0
. In the example below we are adding three lines. The first is for the mandatory entry noted above, the second is for
C:\My Data\*.* /S
and the third is
C:\Project\*.* /S
.
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot" /v "Volume Shadow Copy Data" /t REG_MULTI_SZ /d "$AllVolumes$\System Volume Information\*.* /s\0C:\My Data\*.* /S\0C:\Project\*.* /S" /f
Note: In place of
$AllVolumes$\System Volume Information\*.* /s
you can also use
$AllVolumes$\System Volume Information\*{3808876B-C176-4e48-B7AE-04046E6CC752} /s
Reference:
In Windows Vista and Windows Server 2008 and later, the developer of a VSS writer or application may choose to exclude certain files from shadow copies.
docs.microsoft.com
Sample Batch File
Batch:
@echo off
setlocal enabledelayedexpansion
setlocal enableextensions
cd /d %~dp0
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Check to see if this batch file is being run as Administrator. If it is not, then rerun the batch file ::
:: automatically as admin and terminate the intial instance of the batch file. ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
(Fsutil Dirty Query %SystemDrive%>Nul)||(PowerShell start """%~f0""" -verb RunAs & Exit /B)
::::::::::::::::::::::::::::::::::::::::::::::::
:: End Routine to check if being run as Admin ::
::::::::::::::::::::::::::::::::::::::::::::::::
REM ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
REM :: If you want to add multiple lines, separate each line with a "\0". Here is an example adding ::
REM :: "C:\My Data\*.* /S" and "C:\Project\*.* /S" each on its own line. ::
REM :: ::
REM :: REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot" /v "Volume Shadow Copy Data" /t REG_MULTI_SZ /d "C:\My Data\*.* /S\0C:\Project\*.* /S" /f ::
REM :: ::
REM :: For Macrium Reflect, use the key name of "FilesNotToSnapshotMacriumImage" rather than "FilesNotToSnapshot". Also, be aware that you MUST include an entry for ::
REM :: "$AllVolumes$\System Volume Information\*.* /s" to avoid having the snapshot itself get backed up. The sample above omits this entry to keep the line shorter, but it is a ::
REM :: MANDATORY entry. ::
REM ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshotMacriumImage" /v "Volume Shadow Copy Data" /t REG_MULTI_SZ /d "$AllVolumes$\System Volume Information\*.* /s\0C:\My Data\*.* /S\0C:\Virtual Machines\*.* /S" /f