2 Bacula® - The Network Backup Solution
4 Copyright (C) 2006-2010 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version three of the GNU Affero General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
32 // Copyright transferred from MATRIX-Computer GmbH to
33 // Kern Sibbald by express permission.
36 * Author : Thorsten Engel
37 * Created On : Fri May 06 21:44:00 2006
44 #define b_errno_win32 (1<<29)
49 #define VSS_INIT_RESTORE_AFTER_INIT 1
50 #define VSS_INIT_RESTORE_AFTER_GATHER 2
52 // some forward declarations
62 bool InitializeForBackup(JCR *jcr);
63 bool InitializeForRestore(JCR *jcr, bool (*VssInitCallback)(JCR *, int) = NULL, WCHAR *job_metadata = NULL);
64 virtual bool CreateSnapshots(char* szDriveLetters) = 0;
65 virtual bool CloseBackup() = 0;
66 virtual bool CloseRestore() = 0;
67 virtual WCHAR *GetMetadata() = 0;
68 virtual const char* GetDriverName() = 0;
69 bool GetShadowPath (const char* szFilePath, char* szShadowPath, int nBuflen);
70 bool GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */
72 const size_t GetWriterCount();
73 const char* GetWriterInfo(int nIndex);
74 const int GetWriterState(int nIndex);
75 void DestroyWriterInfo();
76 void AppendWriterInfo(int nState, const char* pszInfo);
77 const bool IsInitialized() { return m_bBackupIsInitialized; };
78 HMODULE GetVssDllHandle() { return m_hLib; };
79 IUnknown *GetVssObject() { return m_pVssObject; };
82 virtual bool Initialize(DWORD dwContext, bool bDuringRestore = FALSE, bool (*VssInitCallback)(JCR *, int) = NULL) = 0;
83 virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync) = 0;
84 virtual void QuerySnapshotSet(GUID snapshotSetID) = 0;
92 IUnknown* m_pVssObject;
93 GUID m_uidCurrentSnapshotSet;
95 // drive A will be stored on position 0,Z on pos. 25
96 wchar_t m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB
97 wchar_t m_szShadowCopyName[26][MAX_PATH]; // approx. 7 KB
99 alist *m_pAlistWriterState;
100 alist *m_pAlistWriterInfoText;
102 bool m_bCoInitializeCalled;
103 bool m_bCoInitializeSecurityCalled;
104 bool m_bDuringRestore; /* true if we are doing a restore */
105 bool m_bBackupIsInitialized;
110 class VSSClientXP:public VSSClient
114 virtual ~VSSClientXP();
115 virtual bool CreateSnapshots(char* szDriveLetters);
116 virtual bool CloseBackup();
117 virtual bool CloseRestore();
118 virtual WCHAR *GetMetadata();
119 virtual const char* GetDriverName() { return "VSS WinXP"; };
121 virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
122 virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
123 virtual void QuerySnapshotSet(GUID snapshotSetID);
124 bool CheckWriterStatus();
127 class VSSClient2003:public VSSClient
131 virtual ~VSSClient2003();
132 virtual bool CreateSnapshots(char* szDriveLetters);
133 virtual bool CloseBackup();
134 virtual bool CloseRestore();
135 virtual WCHAR *GetMetadata();
136 virtual const char* GetDriverName() { return "VSS Win 2003"; };
138 virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
139 virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
140 virtual void QuerySnapshotSet(GUID snapshotSetID);
141 bool CheckWriterStatus();
144 class VSSClientVista:public VSSClient
148 virtual ~VSSClientVista();
149 virtual bool CreateSnapshots(char* szDriveLetters);
150 virtual bool CloseBackup();
151 virtual bool CloseRestore();
152 virtual WCHAR *GetMetadata();
153 virtual const char* GetDriverName() { return "VSS Vista"; };
155 virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
156 virtual bool WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
157 virtual void QuerySnapshotSet(GUID snapshotSetID);
158 bool CheckWriterStatus();
162 extern VSSClient *g_pVSSClient;
164 BOOL VSSPathConvert(const char *szFilePath, char *szShadowPath, int nBuflen);
165 BOOL VSSPathConvertW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen);
167 #endif /* WIN32_VSS */
169 #endif /* __VSS_H_ */