How to exclude files from Volume Shadow Copies

Table of Contents

Case #

The are cases in which you wish to exclude certain files and folders from the Volume Shadow Copy Service (VSS) writer in order to exclude these files from being taken backup as part of the shadow copy service operation.

Potential reasons why you may want to exclude files are the following:

  • Some files are very large large
  • Some files do not undergo significant change between one shadow copy and the next and does not need to be backed up.

Solution #

You can exclude files from VSS writer by using a programmatic method in your code. This involves calling the following methods:

As a systems administrator, you can exclude files from the VSS writer in Volume Shadow Copy configuration as follows.

In the computer section of the file server cluster nodes' registry, add values to the following key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot.

This registry key has REG_MULTI_SZ values for each application whose files can be excluded. The files are specified by fully qualified paths, which can contain the * wildcard. In all cases, the entry is ignored if there are no files that match the path string.

After a file is added to the appropriate registry key value, it is deleted from the shadow copy during creation by the shadow copy optimization writer on a best-effort basis.

If a fully qualified path cannot be specified, then a path can also be implied by using the $UserProfile$ or $AllVolumes$ variable. For example:

  • $UserProfile$\Directory\Subdirectory\FileName.*
  • $AllVolumes$\TemporaryFiles\*.*

To make the path recursive, append " /s" to the end. For example:

  • $UserProfile$\Directory\Subdirectory\FileName.* /s
  • $AllVolumes$\TemporaryFiles\*.* /s

Alternatively you can utilize Group Policy to automate the process of configuring the required registry values.

Source #

https://docs.microsoft.com/en-us/windows/win32/vss/excluding-files-from-shadow-copies

Powered by BetterDocs