2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2018 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Written by James Harper, July 2010
25 #define BACKUP_NODE_TYPE_MACHINE 0x001
26 #define BACKUP_NODE_TYPE_ANNOTATION 0x010
27 #define BACKUP_NODE_TYPE_DISPLAY 0x100
29 #define ESE_BACKUP_INSTANCE_END_ERROR 0x0
30 #define ESE_BACKUP_INSTANCE_END_SUCCESS 0x1
32 #define BACKUP_TYPE_FULL 0x1
33 #define BACKUP_TYPE_LOGS_ONLY 0x2
34 #define BACKUP_TYPE_FULL_WITH_ALL_LOGS 0x3
36 #define RESTORE_CLOSE_ABORT 0x1
37 #define RESTORE_CLOSE_NORMAL 0x0
39 #define ESE_RESTORE_COMPLETE_NOWAIT 0x00010000
40 #define ESE_RESTORE_COMPLETE_ATTACH_DBS 0x00000001
41 #define ESE_RESTORE_KEEP_LOG_FILES 0x00020000
45 struct ESE_ICON_DESCRIPTION {
50 struct BACKUP_NODE_TREE {
53 ESE_ICON_DESCRIPTION iconDescription;
54 struct BACKUP_NODE_TREE *pNextNode;
55 struct BACKUP_NODE_TREE *pChildNode;
58 struct DATABASE_BACKUP_INFO {
59 WCHAR *wszDatabaseDisplayName;
60 uint32_t cwDatabaseStreams;
61 WCHAR *wszDatabaseStreams;
63 uint32_t *rgIconIndexDatabase;
64 uint32_t fDatabaseFlags;
67 struct INSTANCE_BACKUP_INFO {
69 //RPC_STRING wszInstanceName;
70 WCHAR *wszInstanceName;
71 uint32_t ulIconIndexInstance;
73 DATABASE_BACKUP_INFO *rgDatabase;
74 uint32_t cIconDescription;
75 ESE_ICON_DESCRIPTION *rgIconDescription;
80 recoverNotStarted = 1,
86 struct RESTORE_ENVIRONMENT {
87 WCHAR * m_wszRestoreLogPath;
88 WCHAR * m_wszSrcInstanceName;
89 uint32_t m_cDatabases;
90 WCHAR **m_wszDatabaseDisplayName;
91 GUID * m_rguidDatabase;
92 WCHAR * m_wszRestoreInstanceSystemPath;
93 WCHAR * m_wszRestoreInstanceLogPath;
94 WCHAR * m_wszTargetInstanceName;
95 WCHAR ** m_wszDatabaseStreamsS;
96 WCHAR ** m_wszDatabaseStreamsD;
99 WCHAR * m_wszLogBaseName;
100 time_t m_timeLastRestore;
101 RECOVER_STATUS m_statusLastRecover;
102 HRESULT m_hrLastRecover;
103 time_t m_timeLastRecover;
104 WCHAR * m_wszAnnotation;
109 typedef HRESULT (WINAPI *HrESEBackupRestoreGetNodes_t)
111 WCHAR* wszComputerName,
112 BACKUP_NODE_TREE* pBackupNodeTree
115 typedef HRESULT (WINAPI *HrESEBackupPrepare_t)
117 WCHAR* wszBackupServer,
118 WCHAR* wszBackupAnnotation,
119 uint32_t *pcInstanceInfo,
120 INSTANCE_BACKUP_INFO **paInstanceInfo,
121 HCCX *phccxBackupContext
124 typedef HRESULT (WINAPI *HrESEBackupEnd_t)
126 HCCX hccsBackupContext
129 typedef HRESULT (WINAPI *HrESEBackupSetup_t)
131 HCCX hccsBackupContext,
132 uint64_t hInstanceID,
133 uint32_t btBackupType
136 typedef HRESULT (WINAPI *HrESEBackupGetLogAndPatchFiles_t)
138 HCCX hccsBackupContext,
142 typedef HRESULT (WINAPI *HrESEBackupInstanceEnd_t)
144 HCCX hccsBackupContext,
148 typedef HRESULT (WINAPI *HrESEBackupOpenFile_t)
150 HCCX hccsBackupContext,
152 uint32_t cbReadHintSize,
155 uint64_t* rgliSectionSize
158 typedef HRESULT (WINAPI *HrESEBackupReadFile_t)
160 HCCX hccsBackupContext,
167 typedef HRESULT (WINAPI *HrESEBackupCloseFile_t)
169 HCCX hccsBackupContext,
173 typedef HRESULT (WINAPI *HrESEBackupTruncateLogs_t)
175 HCCX hccsBackupContext
178 typedef HRESULT (WINAPI *HrESERestoreOpen_t)
180 WCHAR* wszBackupServer,
181 WCHAR* wszBackupAnnotation,
182 WCHAR* wszSrcInstanceName,
183 WCHAR* wszRestoreLogPath,
184 HCCX* phccxRestoreContext
187 typedef HRESULT (WINAPI *HrESERestoreReopen_t)
189 WCHAR* wszBackupServer,
190 WCHAR* wszBackupAnnotation,
191 WCHAR* wszRestoreLogPath,
192 HCCX* phccxRestoreContext
195 typedef HRESULT (WINAPI *HrESERestoreClose_t)
197 HCCX phccxRestoreContext,
198 uint32_t fRestoreAbort
201 typedef HRESULT (WINAPI *HrESERestoreComplete_t)
203 HCCX phccxRestoreContext,
204 WCHAR* wszCheckpointFilePath,
205 WCHAR* wszLogFilePath,
206 WCHAR* wszTargetInstanceName,
210 typedef HRESULT (WINAPI *HrESERestoreSaveEnvironment_t)
212 HCCX phccxRestoreContext
215 typedef HRESULT (WINAPI *HrESERestoreGetEnvironment_t)
217 HCCX phccxRestoreContext,
218 RESTORE_ENVIRONMENT **ppRestoreEnvironment
221 typedef HRESULT (WINAPI *HrESERestoreAddDatabase_t)
223 HCCX phccxRestoreContext,
224 WCHAR* wszDatabaseDisplayName,
226 WCHAR* wszDatabaseStreamsS,
227 WCHAR** wszDatabaseStreamsD
230 typedef HRESULT (WINAPI *HrESERestoreOpenFile_t)
232 HCCX phccxRestoreContext,
242 ESEErrorMessage(HRESULT result);
244 #define hrLogfileHasBadSignature (HRESULT)0xC8000262L
245 #define hrLogfileNotContiguous (HRESULT)0xC8000263L
246 #define hrCBDatabaseInUse (HRESULT)0xC7FE1F41L
247 #define hrRestoreAtFileLevel (HRESULT)0xC7FF0FA5L
248 #define hrMissingFullBackup (HRESULT)0xC8000230L
249 #define hrBackupInProgress (HRESULT)0xC80001F9L
250 #define hrCBDatabaseNotFound (HRESULT)0xC7FE1F42L
251 #define hrErrorFromESECall (HRESULT)0xC7FF1004L
253 extern HrESEBackupRestoreGetNodes_t HrESEBackupRestoreGetNodes;
254 extern HrESEBackupPrepare_t HrESEBackupPrepare;
255 extern HrESEBackupGetLogAndPatchFiles_t HrESEBackupGetLogAndPatchFiles;
256 extern HrESEBackupTruncateLogs_t HrESEBackupTruncateLogs;
257 extern HrESEBackupEnd_t HrESEBackupEnd;
258 extern HrESEBackupSetup_t HrESEBackupSetup;
259 extern HrESEBackupInstanceEnd_t HrESEBackupInstanceEnd;
260 extern HrESEBackupOpenFile_t HrESEBackupOpenFile;
261 extern HrESEBackupReadFile_t HrESEBackupReadFile;
262 extern HrESEBackupCloseFile_t HrESEBackupCloseFile;
264 extern HrESERestoreOpen_t HrESERestoreOpen;
265 extern HrESERestoreReopen_t HrESERestoreReopen;
266 extern HrESERestoreComplete_t HrESERestoreComplete;
267 extern HrESERestoreClose_t HrESERestoreClose;
268 extern HrESERestoreGetEnvironment_t HrESERestoreGetEnvironment;
269 extern HrESERestoreSaveEnvironment_t HrESERestoreSaveEnvironment;
270 extern HrESERestoreAddDatabase_t HrESERestoreAddDatabase;
271 extern HrESERestoreOpenFile_t HrESERestoreOpenFile;
273 #if !defined(MINGW64) && (_WIN32_WINNT < 0x0500)
274 typedef enum _COMPUTER_NAME_FORMAT {
276 ComputerNameDnsHostname,
277 ComputerNameDnsDomain,
278 ComputerNameDnsFullyQualified,
279 ComputerNamePhysicalNetBIOS,
280 ComputerNamePhysicalDnsHostname,
281 ComputerNamePhysicalDnsDomain,
282 ComputerNamePhysicalDnsFullyQualified,
284 } COMPUTER_NAME_FORMAT;
286 BOOL WINAPI GetComputerNameExW(
287 COMPUTER_NAME_FORMAT NameType,