]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/vss.h
Detect the case where logfiles but no databases are being restored.
[bacula/bacula] / bacula / src / win32 / filed / vss.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2006-2007 Free Software Foundation Europe e.V.
5
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 two of the GNU General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
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.
17
18    You should have received a copy of the GNU 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
21    02110-1301, USA.
22
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.
27 */
28 /*                               -*- Mode: C -*-
29  * vss.h --
30  */
31 //
32 // Copyright transferred from MATRIX-Computer GmbH to
33 //   Kern Sibbald by express permission.
34 /*
35  *
36  * Author          : Thorsten Engel
37  * Created On      : Fri May 06 21:44:00 2006 
38  */
39
40 #ifndef __VSS_H_
41 #define __VSS_H_
42
43 #ifndef b_errno_win32
44 #define b_errno_win32 (1<<29)
45 #endif
46  
47 #ifdef WIN32_VSS
48
49 // some forward declarations
50 struct IVssAsync;
51
52 class VSSClient
53 {
54 public:
55     VSSClient();
56     virtual ~VSSClient();
57
58     // Backup Process
59     BOOL InitializeForBackup();
60     virtual BOOL CreateSnapshots(char* szDriveLetters) = 0;
61     virtual BOOL CloseBackup() = 0;
62     virtual const char* GetDriverName() = 0;
63     BOOL GetShadowPath  (const char* szFilePath, char* szShadowPath, int nBuflen);
64     BOOL GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */
65
66     const size_t GetWriterCount();
67     const char* GetWriterInfo(int nIndex);
68     const int   GetWriterState(int nIndex);
69     void DestroyWriterInfo();
70     void AppendWriterInfo(int nState, const char* pszInfo);
71     const BOOL  IsInitialized() { return m_bBackupIsInitialized; };
72          
73 private:
74     virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore = FALSE) = 0;
75     virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync*  pAsync) = 0;
76     virtual void QuerySnapshotSet(GUID snapshotSetID) = 0;
77
78 protected:
79     HMODULE                         m_hLib;
80
81     BOOL                            m_bCoInitializeCalled;
82     BOOL                            m_bCoInitializeSecurityCalled;
83     DWORD                           m_dwContext;
84
85     IUnknown*                       m_pVssObject;
86     GUID                            m_uidCurrentSnapshotSet;
87     // TRUE if we are during restore
88     BOOL                            m_bDuringRestore;
89     BOOL                            m_bBackupIsInitialized;
90
91     // drive A will be stored on position 0,Z on pos. 25
92     wchar_t                           m_wszUniqueVolumeName[26][MAX_PATH]; // approx. 7 KB
93     wchar_t                           m_szShadowCopyName[26][MAX_PATH]; // approx. 7 KB
94     
95     void*                           m_pAlistWriterState;
96     void*                           m_pAlistWriterInfoText;
97 };
98
99 class VSSClientXP:public VSSClient
100 {
101 public:
102    VSSClientXP();
103    virtual ~VSSClientXP();
104    virtual BOOL CreateSnapshots(char* szDriveLetters);
105    virtual BOOL CloseBackup();
106    virtual const char* GetDriverName() { return "VSS WinXP"; };
107 private:
108    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
109    virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync* pAsync);
110    virtual void QuerySnapshotSet(GUID snapshotSetID);
111    BOOL CheckWriterStatus();   
112 };
113
114 class VSSClient2003:public VSSClient
115 {
116 public:
117    VSSClient2003();
118    virtual ~VSSClient2003();
119    virtual BOOL CreateSnapshots(char* szDriveLetters);
120    virtual BOOL CloseBackup();   
121    virtual const char* GetDriverName() { return "VSS Win 2003"; };
122 private:
123    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
124    virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
125    virtual void QuerySnapshotSet(GUID snapshotSetID);
126    BOOL CheckWriterStatus();
127 };
128
129 class VSSClientVista:public VSSClient
130 {
131 public:
132    VSSClientVista();
133    virtual ~VSSClientVista();
134    virtual BOOL CreateSnapshots(char* szDriveLetters);
135    virtual BOOL CloseBackup();   
136    virtual const char* GetDriverName() { return "VSS Vista"; };
137 private:
138    virtual BOOL Initialize(DWORD dwContext, BOOL bDuringRestore);
139    virtual BOOL WaitAndCheckForAsyncOperation(IVssAsync*  pAsync);
140    virtual void QuerySnapshotSet(GUID snapshotSetID);
141    BOOL CheckWriterStatus();
142 };
143
144
145 extern VSSClient *g_pVSSClient;
146
147 #endif /* WIN32_VSS */
148
149 #endif /* __VSS_H_ */