How do I exclude certain files and folders from Backup Restore / VSS / shadow copy?

I have Windows Vista Basic.

I am trying to exclude certain files from being shadow copied / involved in backup and restore / a part of VSS.  I have already tried (in cmd):

hkey_local_machine\system\currentcontrolset\control\backuprestore\filesnottosnapshot

It did not work.  I would like to exclude my entire Music folder, temp files, etc.

Could you please let me know how to do this?  Is the command code incorrect?  Etc?

Thanks!
Hi Adventuresaurusgirl,

I found what I believe is the data you are looking for here.
Here is the link it came from.
http://msdn.microsoft.com/en-us/library/aa819132(VS.85).aspx

Excluding Files from Shadow Copies

In Windows Vista and Windows Server 2008, the developer of a VSS writer or application may choose to exclude certain files from shadow copies.

The performance impact and shadow copy storage area (also called "diff area") usage of a file in a shadow copy are directly related to the amount of change in the file's contents after the shadow copy is created. In addition, excluding files from shadow copies may slow down shadow copy creation.

For these reasons, a file should be excluded from shadow copies only if it is large, undergoes significant change between one shadow copy and the next, and does not need to be backed up.

You should only exclude files that belong to your application.

If the VSS_VOLSNAP_ATTR_NO_AUTORECOVERY flag is set in the shadow copy context, this means that auto-recovery is disabled, and no files can be excluded from the shadow copy. For more information, see the _VSS_VOLUME_SNAPSHOT_ATTRIBUTES enumeration.

Using the AddExcludeFilesFromSnapshot Method

A VSS writer can exclude files from a shadow copy as follows:

  1. Call the IVssCreateWriterMetadataEx::AddExcludeFilesFromSnapshot method to report the files to be excluded.
  2. In the writer's CVssWriter::OnPostSnapshot method, delete the files from the shadow copy.
Using the FilesNotToSnapshot Registry Key

A VSS application can delete files from a shadow copy during shadow copy creation by using the following registry 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
The $UserProfile$ variable causes the path string to be applied to all user profiles on the computer. The user profiles are enumerated by examining the following registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList

The $AllVolumes$ variable causes the path string to be applied to all shadow copies on the computer. For example, suppose the path is "$AllVolumes$\TemporaryFiles\*.* /s", and the computer has three volumes: C:, D:, and E:. If C: and E: contain the path "\TemporaryFiles\", and volume D: contains only the path D:\Data\, the directory tree C:\TemporaryFiles\ is deleted from shadow copies of C:, and the directory tree E:\TemporaryFiles\ is deleted from shadow copies of E:.

Administrators can disable expansion of the $UserProfile$ variable by using the following registry key:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Vss\Settings

Under this registry key, specify DisableUserProfileExpansion for the value name, REG_DWORD for the value type, and a nonzero value for the value data.






Matt
Microsoft Answers Support Engineer
Visit our Microsoft Answers Feedback Forum and let us know what you think.
Matt Hudson

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hi Matt,

Thank you for your quick reply.

I have spent the last couple of days trying to figure this out.  I must admit, I am not exactly that technically advanced.  I don't know C++ or any programming languages.  I am having serious issues understanding 90% of the posting above.

Would you happen to know a way to explain it better or list out the steps I should be taking?  I already reduced the VSS volume size which is a good start, but would really like to exclude giant files that aren't supposed to be involved in VSS anyway.

Thanks!

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Although this question is almost two years old, what worked for me is to use the registry editor to find the key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToBackup then add a new "multi-string value".  I named the value something useful ("Shared Music") then set its value to the folder/files I wanted to exclude ("D:\Users\Public\Music\*.* /s").  (The "/s" on the end means "and all subdirectories".)

 

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Adding entry to FilesNotToBackup worked ? I tried, but no luck. 
I tried to mount the VSS snapshot of the C:\ from vshadow and try to see, if it excludes the files from the VSS, but I still see all the files in the snapshot mount.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

If we read the MSDN links carefully, it indicates the files are not removed from the VSS, but instead leaves the task to the writer. Which means, VSS will still have the data, but writer
might exclude them to sync or worry about its data integrity. But, what we want is to remove the file from the snapshot, which does not seem to be possible. Can anybody please confirm ?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I have the same problem. Could someone answer if it is possible to exclude file/directory from shadow copy during creation?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 5, 2020 Views 9,334 Applies to: