I found out about the new Feature from .NET 6 and onwards "Shadow Copy". With just enabling it and setting a Folder for the Shadow copy, the whole Application Folder is copied. If my Application has some Files inside this Folder which dont need to be "shadow copied", is it currently possible to exclude some folders/files? Or do i need to move those files to a different folder outside the hosted IIS Application. That would mean tho, that i would need to set up permissions for the server to be able to access them and serve them to the web, right?
Asked
Active
Viewed 88 times
1 Answers
0
Volume shadow copy cannot exclude certain files or folders. As you said, you can move these files to other folders outside of hosting the IIS application, and required administrative privileges.
You may try to use the FilesNotToSnapshot registry key to specify the files that you want to exclude from shadow copies. The developer of a VSS writer or application may choose to exclude certain files from shadow copies. A VSS writer can exclude files from a shadow copy as follows:
- Call the IVssCreateWriterMetadataEx::AddExcludeFilesFromSnapshot method to report the files to be excluded.
- In the writer's CVssWriter::OnPostSnapshot method, delete the files from the shadow copy.
You can refer to the official doc for Excluding Files from Shadow Copies: https://learn.microsoft.com/en-us/windows/win32/vss/excluding-files-from-shadow-copies#using-the-addexcludefilesfromsnapshot-method.

TengFeiXie
- 176
- 5
-
If i add an registry key with the folder i want to exlude it still gets copied. So either .net (6) does'nt check that entry when doing its thing or i did somethign wrong. Should the name of that reg entry be something specific? – matrixPill Jun 21 '23 at 13:30
-
The registry just needs to be named FilesNotToSnapshot. 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. Files are deleted from a shadow copy on a best-effort basis. This means that they are not guaranteed to be deleted. – TengFeiXie Jun 23 '23 at 03:31
-
Ok sorry maybe i am still clueless. I am not in process of writing the shadowcopy myself. I was just trying to use the "new" feature from .net 6 where the aplication hosted in IIS creates automaticly creates an shadow copy so that you could update the website without manually shutting it down to free the loaded assamblys. – matrixPill Jun 23 '23 at 07:52
-
Ok, about Shadow Copying Assemblies, the official documentation also gives a detailed explanation: https://learn.microsoft.com/en-us/dotnet/framework/app-domains/shadow-copy-assemblies. Shadow copying enables assemblies that are used in an application domain to be updated without unloading the application domain. – TengFeiXie Jun 26 '23 at 09:39