2 Bacula® - The Network Backup Solution
4 Copyright (C) 2008-2009 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, which is
11 listed in the file LICENSE.
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.
29 * Written by James Harper, October 2008
34 #define BACKUP_NODE_TYPE_MACHINE 0x001
35 #define BACKUP_NODE_TYPE_ANNOTATION 0x010
36 #define BACKUP_NODE_TYPE_DISPLAY 0x100
38 #define ESE_BACKUP_INSTANCE_END_ERROR 0x0
39 #define ESE_BACKUP_INSTANCE_END_SUCCESS 0x1
41 #define BACKUP_TYPE_FULL 0x1
42 #define BACKUP_TYPE_LOGS_ONLY 0x2
43 #define BACKUP_TYPE_FULL_WITH_ALL_LOGS 0x3
45 #define RESTORE_CLOSE_ABORT 0x1
46 #define RESTORE_CLOSE_NORMAL 0x0
48 #define ESE_RESTORE_COMPLETE_NOWAIT 0x00010000
49 #define ESE_RESTORE_COMPLETE_ATTACH_DBS 0x00000001
50 #define ESE_RESTORE_KEEP_LOG_FILES 0x00020000
54 struct ESE_ICON_DESCRIPTION {
59 struct BACKUP_NODE_TREE {
62 ESE_ICON_DESCRIPTION iconDescription;
63 struct BACKUP_NODE_TREE *pNextNode;
64 struct BACKUP_NODE_TREE *pChildNode;
67 struct DATABASE_BACKUP_INFO {
68 WCHAR *wszDatabaseDisplayName;
69 uint32_t cwDatabaseStreams;
70 WCHAR *wszDatabaseStreams;
72 uint32_t *rgIconIndexDatabase;
73 uint32_t fDatabaseFlags;
76 struct INSTANCE_BACKUP_INFO {
78 //RPC_STRING wszInstanceName;
79 WCHAR *wszInstanceName;
80 uint32_t ulIconIndexInstance;
82 DATABASE_BACKUP_INFO *rgDatabase;
83 uint32_t cIconDescription;
84 ESE_ICON_DESCRIPTION *rgIconDescription;
89 recoverNotStarted = 1,
95 struct RESTORE_ENVIRONMENT {
96 WCHAR * m_wszRestoreLogPath;
97 WCHAR * m_wszSrcInstanceName;
98 uint32_t m_cDatabases;
99 WCHAR **m_wszDatabaseDisplayName;
100 GUID * m_rguidDatabase;
101 WCHAR * m_wszRestoreInstanceSystemPath;
102 WCHAR * m_wszRestoreInstanceLogPath;
103 WCHAR * m_wszTargetInstanceName;
104 WCHAR ** m_wszDatabaseStreamsS;
105 WCHAR ** m_wszDatabaseStreamsD;
107 uint32_t m_ulGenHigh;
108 WCHAR * m_wszLogBaseName;
109 time_t m_timeLastRestore;
110 RECOVER_STATUS m_statusLastRecover;
111 HRESULT m_hrLastRecover;
112 time_t m_timeLastRecover;
113 WCHAR * m_wszAnnotation;
118 typedef HRESULT (WINAPI *HrESEBackupRestoreGetNodes_t)
120 WCHAR* wszComputerName,
121 BACKUP_NODE_TREE* pBackupNodeTree
124 typedef HRESULT (WINAPI *HrESEBackupPrepare_t)
126 WCHAR* wszBackupServer,
127 WCHAR* wszBackupAnnotation,
128 uint32_t *pcInstanceInfo,
129 INSTANCE_BACKUP_INFO **paInstanceInfo,
130 HCCX *phccxBackupContext
133 typedef HRESULT (WINAPI *HrESEBackupEnd_t)
135 HCCX hccsBackupContext
138 typedef HRESULT (WINAPI *HrESEBackupSetup_t)
140 HCCX hccsBackupContext,
141 uint64_t hInstanceID,
142 uint32_t btBackupType
145 typedef HRESULT (WINAPI *HrESEBackupGetLogAndPatchFiles_t)
147 HCCX hccsBackupContext,
151 typedef HRESULT (WINAPI *HrESEBackupInstanceEnd_t)
153 HCCX hccsBackupContext,
157 typedef HRESULT (WINAPI *HrESEBackupOpenFile_t)
159 HCCX hccsBackupContext,
161 uint32_t cbReadHintSize,
164 uint64_t* rgliSectionSize
167 typedef HRESULT (WINAPI *HrESEBackupReadFile_t)
169 HCCX hccsBackupContext,
176 typedef HRESULT (WINAPI *HrESEBackupCloseFile_t)
178 HCCX hccsBackupContext,
182 typedef HRESULT (WINAPI *HrESEBackupTruncateLogs_t)
184 HCCX hccsBackupContext
187 typedef HRESULT (WINAPI *HrESERestoreOpen_t)
189 WCHAR* wszBackupServer,
190 WCHAR* wszBackupAnnotation,
191 WCHAR* wszSrcInstanceName,
192 WCHAR* wszRestoreLogPath,
193 HCCX* phccxRestoreContext
196 typedef HRESULT (WINAPI *HrESERestoreReopen_t)
198 WCHAR* wszBackupServer,
199 WCHAR* wszBackupAnnotation,
200 WCHAR* wszRestoreLogPath,
201 HCCX* phccxRestoreContext
204 typedef HRESULT (WINAPI *HrESERestoreClose_t)
206 HCCX phccxRestoreContext,
207 uint32_t fRestoreAbort
210 typedef HRESULT (WINAPI *HrESERestoreComplete_t)
212 HCCX phccxRestoreContext,
213 WCHAR* wszCheckpointFilePath,
214 WCHAR* wszLogFilePath,
215 WCHAR* wszTargetInstanceName,
219 typedef HRESULT (WINAPI *HrESERestoreSaveEnvironment_t)
221 HCCX phccxRestoreContext
224 typedef HRESULT (WINAPI *HrESERestoreGetEnvironment_t)
226 HCCX phccxRestoreContext,
227 RESTORE_ENVIRONMENT **ppRestoreEnvironment
230 typedef HRESULT (WINAPI *HrESERestoreAddDatabase_t)
232 HCCX phccxRestoreContext,
233 WCHAR* wszDatabaseDisplayName,
235 WCHAR* wszDatabaseStreamsS,
236 WCHAR** wszDatabaseStreamsD
239 typedef HRESULT (WINAPI *HrESERestoreOpenFile_t)
241 HCCX phccxRestoreContext,
251 ESEErrorMessage(HRESULT result);
253 #define hrLogfileHasBadSignature (HRESULT)0xC8000262L
254 #define hrLogfileNotContiguous (HRESULT)0xC8000263L
255 #define hrCBDatabaseInUse (HRESULT)0xC7FE1F41L
256 #define hrRestoreAtFileLevel (HRESULT)0xC7FF0FA5L
257 #define hrMissingFullBackup (HRESULT)0xC8000230L
258 #define hrBackupInProgress (HRESULT)0xC80001F9L
259 #define hrCBDatabaseNotFound (HRESULT)0xC7FE1F42L
260 #define hrErrorFromESECall (HRESULT)0xC7FF1004L
262 extern HrESEBackupRestoreGetNodes_t HrESEBackupRestoreGetNodes;
263 extern HrESEBackupPrepare_t HrESEBackupPrepare;
264 extern HrESEBackupGetLogAndPatchFiles_t HrESEBackupGetLogAndPatchFiles;
265 extern HrESEBackupTruncateLogs_t HrESEBackupTruncateLogs;
266 extern HrESEBackupEnd_t HrESEBackupEnd;
267 extern HrESEBackupSetup_t HrESEBackupSetup;
268 extern HrESEBackupInstanceEnd_t HrESEBackupInstanceEnd;
269 extern HrESEBackupOpenFile_t HrESEBackupOpenFile;
270 extern HrESEBackupReadFile_t HrESEBackupReadFile;
271 extern HrESEBackupCloseFile_t HrESEBackupCloseFile;
273 extern HrESERestoreOpen_t HrESERestoreOpen;
274 extern HrESERestoreReopen_t HrESERestoreReopen;
275 extern HrESERestoreComplete_t HrESERestoreComplete;
276 extern HrESERestoreClose_t HrESERestoreClose;
277 extern HrESERestoreGetEnvironment_t HrESERestoreGetEnvironment;
278 extern HrESERestoreSaveEnvironment_t HrESERestoreSaveEnvironment;
279 extern HrESERestoreAddDatabase_t HrESERestoreAddDatabase;
280 extern HrESERestoreOpenFile_t HrESERestoreOpenFile;
282 #if !defined(MINGW64) && (_WIN32_WINNT < 0x0500)
283 typedef enum _COMPUTER_NAME_FORMAT {
285 ComputerNameDnsHostname,
286 ComputerNameDnsDomain,
287 ComputerNameDnsFullyQualified,
288 ComputerNamePhysicalNetBIOS,
289 ComputerNamePhysicalDnsHostname,
290 ComputerNamePhysicalDnsDomain,
291 ComputerNamePhysicalDnsFullyQualified,
293 } COMPUTER_NAME_FORMAT;
295 BOOL WINAPI GetComputerNameExW(
296 COMPUTER_NAME_FORMAT NameType,