summaryrefslogtreecommitdiff
path: root/lib/ShadowCopy/shadow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ShadowCopy/shadow.cpp')
-rw-r--r--lib/ShadowCopy/shadow.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/ShadowCopy/shadow.cpp b/lib/ShadowCopy/shadow.cpp
index e915663f..adc7c5c2 100644
--- a/lib/ShadowCopy/shadow.cpp
+++ b/lib/ShadowCopy/shadow.cpp
@@ -89,8 +89,27 @@ shadow::ShadowData createShadowCopy(const wchar_t* volumeName) //throw SysError
}
ZEN_COM_CHECK(backupComp->InitializeForBackup()); //throw SysError
+
+ //SetContext() only required if different than the default, VSS_CTX_BACKUP; not implemented on XP!!!
+ //ZEN_COM_CHECK(backupComp->SetContext(VSS_CTX_BACKUP)); //throw SysError
+
ZEN_COM_CHECK(backupComp->SetBackupState(false, false, VSS_BT_FULL)); //throw SysError
+
+ //the Shadow Copy Optimization Writer removes items it considers non-essential,
+ //http://msdn.microsoft.com/en-US/library/bb968827#shadow_copy_optimization_writer
+ //like the exclusions in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot
+ //http://msdn.microsoft.com/en-us/library/aa819132%28v=vs.85%29.aspx
+ //Outlook *.ost files in particular:
+ //https://sourceforge.net/p/freefilesync/discussion/help/thread/722dcbfb
+ const VSS_ID disabledWriters[] = { { 0x4dc3bdd4, 0xab48, 0x4d07, { 0xad, 0xb0, 0x3b, 0xee, 0x29, 0x26, 0xfd, 0x7f } } }; //Shadow Copy Optimization Writer
+ {
+ HRESULT hr = backupComp->DisableWriterClasses(disabledWriters, 1);
+ if (FAILED(hr) && hr != E_NOTIMPL) //DisableWriterClasses() is not implemented on Windows XP, although MSDN documented otherwise!
+ throw SysError(formatComError(L"Error calling \"backupComp->DisableWriterClasses\".", hr));
+ }
+
+
auto waitForComFuture = [](IVssAsync& fut)
{
ZEN_COM_CHECK(fut.Wait());
bgstack15