Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

573 lines
14 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. vsbackup.h
  5. Abstract:
  6. Declaration of backup interfaces IVssExamineWriterMetadata and
  7. IVssBackupComponents, IVssWMComponent
  8. Brian Berkowitz [brianb] 3/13/2000
  9. TBD:
  10. Add comments.
  11. Revision History:
  12. Name Date Comments
  13. brianb 03/30/2000 Created
  14. brianb 04/18/2000 Added IVssCancelCallback
  15. brianb 05/03/2000 Changed IVssWriter::Initialize method
  16. brianb 05/16/2000 Remove cancel stuff
  17. mikejohn 05/24/2000 Changed parameters on SimulateXxxx() calls
  18. mikejohn 09/18/2000 176860: Added calling convention methods where missing
  19. ssteiner 11/10/2000 143801 MOve SimulateSnashotXxxx() calls to be hosted by VssSvc
  20. --*/
  21. #ifndef _VSBACKUP_H_
  22. #define _VSBACKUP_H_
  23. // description of a component
  24. typedef struct _VSS_COMPONENTINFO
  25. {
  26. VSS_COMPONENT_TYPE type; // either VSS_CT_DATABASE or VSS_CT_FILEGROUP
  27. BSTR bstrLogicalPath; // logical path to component
  28. BSTR bstrComponentName; // component name
  29. BSTR bstrCaption; // description of component
  30. BYTE *pbIcon; // icon
  31. UINT cbIcon; // icon
  32. bool bRestoreMetadata; // whether component supplies restore metadata
  33. bool bNotifyOnBackupComplete; // whether component needs to be informed if backup was successful
  34. bool bSelectable; // is component selectable
  35. bool bSelectableForRestore; // is component selectable for restore
  36. DWORD dwComponentFlags; // extra attribute flags for the component
  37. UINT cFileCount; // # of files in file group
  38. UINT cDatabases; // # of database files
  39. UINT cLogFiles; // # of log files
  40. UINT cDependencies; // # of components that this component depends on
  41. } VSS_COMPONENTINFO;
  42. typedef const VSS_COMPONENTINFO *PVSSCOMPONENTINFO;
  43. // component information
  44. class IVssWMComponent : public IUnknown
  45. {
  46. public:
  47. // get component information
  48. STDMETHOD(GetComponentInfo)(PVSSCOMPONENTINFO *ppInfo) = 0;
  49. // free component information
  50. STDMETHOD(FreeComponentInfo)(PVSSCOMPONENTINFO pInfo) = 0;
  51. // obtain a specific file in a file group
  52. STDMETHOD(GetFile)
  53. (
  54. IN UINT iFile,
  55. OUT IVssWMFiledesc **ppFiledesc
  56. ) = 0;
  57. // obtain a specific physical database file for a database
  58. STDMETHOD(GetDatabaseFile)
  59. (
  60. IN UINT iDBFile,
  61. OUT IVssWMFiledesc **ppFiledesc
  62. ) = 0;
  63. // obtain a specific physical log file for a database
  64. STDMETHOD(GetDatabaseLogFile)
  65. (
  66. IN UINT iDbLogFile,
  67. OUT IVssWMFiledesc **ppFiledesc
  68. ) = 0;
  69. STDMETHOD(GetDependency)
  70. (
  71. IN UINT iDependency,
  72. OUT IVssWMDependency **ppDependency
  73. ) = 0;
  74. };
  75. // interface to examine writer metadata
  76. class IVssExamineWriterMetadata : public IUnknown
  77. {
  78. public:
  79. // obtain identity of the writer
  80. STDMETHOD(GetIdentity)
  81. (
  82. OUT VSS_ID *pidInstance,
  83. OUT VSS_ID *pidWriter,
  84. OUT BSTR *pbstrWriterName,
  85. OUT VSS_USAGE_TYPE *pUsage,
  86. OUT VSS_SOURCE_TYPE *pSource
  87. ) = 0;
  88. // obtain number of include files, exclude files, and components
  89. STDMETHOD(GetFileCounts)
  90. (
  91. OUT UINT *pcIncludeFiles,
  92. OUT UINT *pcExcludeFiles,
  93. OUT UINT *pcComponents
  94. ) = 0;
  95. // obtain specific include files
  96. STDMETHOD(GetIncludeFile)
  97. (
  98. IN UINT iFile,
  99. OUT IVssWMFiledesc **ppFiledesc
  100. ) = 0;
  101. // obtain specific exclude files
  102. STDMETHOD(GetExcludeFile)
  103. (
  104. IN UINT iFile,
  105. OUT IVssWMFiledesc **ppFiledesc
  106. ) = 0;
  107. // obtain specific component
  108. STDMETHOD(GetComponent)
  109. (
  110. IN UINT iComponent,
  111. OUT IVssWMComponent **ppComponent
  112. ) = 0;
  113. // obtain restoration method
  114. STDMETHOD(GetRestoreMethod)
  115. (
  116. OUT VSS_RESTOREMETHOD_ENUM *pMethod,
  117. OUT BSTR *pbstrService,
  118. OUT BSTR *pbstrUserProcedure,
  119. OUT VSS_WRITERRESTORE_ENUM *pwriterRestore,
  120. OUT bool *pbRebootRequired,
  121. UINT *pcMappings
  122. ) = 0;
  123. // obtain a specific alternative location mapping
  124. STDMETHOD(GetAlternateLocationMapping)
  125. (
  126. IN UINT iMapping,
  127. OUT IVssWMFiledesc **ppFiledesc
  128. ) = 0;
  129. // get the backup schema
  130. STDMETHOD(GetBackupSchema)
  131. (
  132. OUT DWORD *pdwSchemaMask
  133. ) = 0;
  134. // obtain reference to actual XML document
  135. STDMETHOD(GetDocument)(IXMLDOMDocument **pDoc) = 0;
  136. // convert document to a XML string
  137. STDMETHOD(SaveAsXML)(BSTR *pbstrXML) = 0;
  138. // load document from an XML string
  139. STDMETHOD(LoadFromXML)(BSTR bstrXML) = 0;
  140. };
  141. class IVssWriterComponentsExt :
  142. public IVssWriterComponents,
  143. public IUnknown
  144. {
  145. };
  146. // backup components interface
  147. class IVssBackupComponents : public IUnknown
  148. {
  149. public:
  150. // get count of writer components
  151. STDMETHOD(GetWriterComponentsCount)(OUT UINT *pcComponents) = 0;
  152. // obtain a specific writer component
  153. STDMETHOD(GetWriterComponents)
  154. (
  155. IN UINT iWriter,
  156. OUT IVssWriterComponentsExt **ppWriter
  157. ) = 0;
  158. // initialize and create BACKUP_COMPONENTS document
  159. STDMETHOD(InitializeForBackup)(IN BSTR bstrXML = NULL) = 0;
  160. // set state describing backup
  161. STDMETHOD(SetBackupState)
  162. (
  163. IN bool bSelectComponents,
  164. IN bool bBackupBootableSystemState,
  165. IN VSS_BACKUP_TYPE backupType,
  166. IN bool bPartialFileSupport = false
  167. ) = 0;
  168. STDMETHOD(InitializeForRestore)(IN BSTR bstrXML) = 0;
  169. // set state describing restore
  170. STDMETHOD(SetRestoreState)
  171. (
  172. VSS_RESTORE_TYPE restoreType
  173. ) = 0;
  174. // gather writer metadata
  175. STDMETHOD(GatherWriterMetadata)
  176. (
  177. OUT IVssAsync **pAsync
  178. ) = 0;
  179. // get count of writers with metadata
  180. STDMETHOD(GetWriterMetadataCount)
  181. (
  182. OUT UINT *pcWriters
  183. ) = 0;
  184. // get writer metadata for a specific writer
  185. STDMETHOD(GetWriterMetadata)
  186. (
  187. IN UINT iWriter,
  188. OUT VSS_ID *pidInstance,
  189. OUT IVssExamineWriterMetadata **ppMetadata
  190. ) = 0;
  191. // free writer metadata
  192. STDMETHOD(FreeWriterMetadata)() = 0;
  193. // add a component to the BACKUP_COMPONENTS document
  194. STDMETHOD(AddComponent)
  195. (
  196. IN VSS_ID instanceId,
  197. IN VSS_ID writerId,
  198. IN VSS_COMPONENT_TYPE ct,
  199. IN LPCWSTR wszLogicalPath,
  200. IN LPCWSTR wszComponentName
  201. ) = 0;
  202. // dispatch PrepareForBackup event to writers
  203. STDMETHOD(PrepareForBackup)
  204. (
  205. OUT IVssAsync **ppAsync
  206. ) = 0;
  207. // abort the backup
  208. STDMETHOD(AbortBackup)() = 0;
  209. // dispatch the Identify event so writers can expose their metadata
  210. STDMETHOD(GatherWriterStatus)
  211. (
  212. OUT IVssAsync **pAsync
  213. ) = 0;
  214. // get count of writers with status
  215. STDMETHOD(GetWriterStatusCount)
  216. (
  217. OUT UINT *pcWriters
  218. ) = 0;
  219. STDMETHOD(FreeWriterStatus)() = 0;
  220. STDMETHOD(GetWriterStatus)
  221. (
  222. IN UINT iWriter,
  223. OUT VSS_ID *pidInstance,
  224. OUT VSS_ID *pidWriter,
  225. OUT BSTR *pbstrWriter,
  226. OUT VSS_WRITER_STATE *pnStatus,
  227. OUT HRESULT *phResultFailure
  228. ) = 0;
  229. // indicate whether backup succeeded on a component
  230. STDMETHOD(SetBackupSucceeded)
  231. (
  232. IN VSS_ID instanceId,
  233. IN VSS_ID writerId,
  234. IN VSS_COMPONENT_TYPE ct,
  235. IN LPCWSTR wszLogicalPath,
  236. IN LPCWSTR wszComponentName,
  237. IN bool bSucceded
  238. ) = 0;
  239. // set backup options for the writer
  240. STDMETHOD(SetBackupOptions)
  241. (
  242. IN VSS_ID writerId,
  243. IN VSS_COMPONENT_TYPE ct,
  244. IN LPCWSTR wszLogicalPath,
  245. IN LPCWSTR wszComponentName,
  246. IN LPCWSTR wszBackupOptions
  247. ) = 0;
  248. // indicate that a given component is selected to be restored
  249. STDMETHOD(SetSelectedForRestore)
  250. (
  251. IN VSS_ID writerId,
  252. IN VSS_COMPONENT_TYPE ct,
  253. IN LPCWSTR wszLogicalPath,
  254. IN LPCWSTR wszComponentName,
  255. IN bool bSelectedForRestore
  256. ) = 0;
  257. // set restore options for the writer
  258. STDMETHOD(SetRestoreOptions)
  259. (
  260. IN VSS_ID writerId,
  261. IN VSS_COMPONENT_TYPE ct,
  262. IN LPCWSTR wszLogicalPath,
  263. IN LPCWSTR wszComponentName,
  264. IN LPCWSTR wszRestoreOptions
  265. ) = 0;
  266. // indicate that additional restores will follow
  267. STDMETHOD(SetAdditionalRestores)
  268. (
  269. IN VSS_ID writerId,
  270. IN VSS_COMPONENT_TYPE ct,
  271. IN LPCWSTR wszLogicalPath,
  272. IN LPCWSTR wszComponentName,
  273. IN bool bAdditionalRestores
  274. ) = 0;
  275. // set the backup stamp that the differential or incremental
  276. // backup is based on
  277. STDMETHOD(SetPreviousBackupStamp)
  278. (
  279. IN VSS_ID writerId,
  280. IN VSS_COMPONENT_TYPE ct,
  281. IN LPCWSTR wszLogicalPath,
  282. IN LPCWSTR wszComponentName,
  283. IN LPCWSTR wszPreviousBackupStamp
  284. ) = 0;
  285. // save BACKUP_COMPONENTS document as XML string
  286. STDMETHOD(SaveAsXML)(BSTR *pbstrXML) = 0;
  287. // signal BackupComplete event to the writers
  288. STDMETHOD(BackupComplete)(OUT IVssAsync **ppAsync) = 0;
  289. // add an alternate mapping on restore
  290. STDMETHOD(AddAlternativeLocationMapping)
  291. (
  292. IN VSS_ID writerId,
  293. IN VSS_COMPONENT_TYPE componentType,
  294. IN LPCWSTR wszLogicalPath,
  295. IN LPCWSTR wszComponentName,
  296. IN LPCWSTR wszPath,
  297. IN LPCWSTR wszFilespec,
  298. IN bool bRecursive,
  299. IN LPCWSTR wszDestination
  300. ) = 0;
  301. // add a subcomponent to be restored
  302. STDMETHOD(AddRestoreSubcomponent)
  303. (
  304. IN VSS_ID writerId,
  305. IN VSS_COMPONENT_TYPE componentType,
  306. IN LPCWSTR wszLogicalPath,
  307. IN LPCWSTR wszComponentName,
  308. IN LPCWSTR wszSubComponentLogicalPath,
  309. IN LPCWSTR wszSubComponentName,
  310. IN bool bRepair
  311. ) = 0;
  312. // requestor indicates whether files were successfully restored
  313. STDMETHOD(SetFileRestoreStatus)
  314. (
  315. IN VSS_ID writerId,
  316. IN VSS_COMPONENT_TYPE ct,
  317. IN LPCWSTR wszLogicalPath,
  318. IN LPCWSTR wszComponentName,
  319. IN VSS_FILE_RESTORE_STATUS status
  320. ) = 0;
  321. // add a new location target for a file to be restored
  322. STDMETHOD(AddNewTarget)
  323. (
  324. IN VSS_ID writerId,
  325. IN VSS_COMPONENT_TYPE ct,
  326. IN LPCWSTR wszLogicalPath,
  327. IN LPCWSTR wszComponentName,
  328. IN LPCWSTR wszPath,
  329. IN LPCWSTR wszFileName,
  330. IN bool bRecursive,
  331. IN LPCWSTR wszAlternatePath
  332. ) = 0;
  333. // add a new location for the ranges file in case it was restored to
  334. // a different location
  335. STDMETHOD(SetRangesFilePath)
  336. (
  337. IN VSS_ID writerId,
  338. IN VSS_COMPONENT_TYPE ct,
  339. IN LPCWSTR wszLogicalPath,
  340. IN LPCWSTR wszComponentName,
  341. IN UINT iPartialFile,
  342. IN LPCWSTR wszRangesFile
  343. ) = 0;
  344. // signal PreRestore event to the writers
  345. STDMETHOD(PreRestore)(OUT IVssAsync **ppAsync) = 0;
  346. // signal PostRestore event to the writers
  347. STDMETHOD(PostRestore)(OUT IVssAsync **ppAsync) = 0;
  348. // Called to set the context for subsequent snapshot-related operations
  349. STDMETHOD(SetContext)
  350. (
  351. IN LONG lContext
  352. ) = 0;
  353. // start a snapshot set
  354. STDMETHOD(StartSnapshotSet)
  355. (
  356. OUT VSS_ID *pSnapshotSetId
  357. ) = 0;
  358. // add a volume to a snapshot set
  359. STDMETHOD(AddToSnapshotSet)
  360. (
  361. IN VSS_PWSZ pwszVolumeName,
  362. IN VSS_ID ProviderId,
  363. OUT VSS_ID *pidSnapshot
  364. ) = 0;
  365. // create the snapshot set
  366. STDMETHOD(DoSnapshotSet)
  367. (
  368. OUT IVssAsync** ppAsync
  369. ) = 0;
  370. STDMETHOD(DeleteSnapshots)
  371. (
  372. IN VSS_ID SourceObjectId,
  373. IN VSS_OBJECT_TYPE eSourceObjectType,
  374. IN BOOL bForceDelete,
  375. IN LONG* plDeletedSnapshots,
  376. IN VSS_ID* pNondeletedSnapshotID
  377. ) = 0;
  378. STDMETHOD(ImportSnapshots)
  379. (
  380. OUT IVssAsync** ppAsync
  381. ) = 0;
  382. STDMETHOD(BreakSnapshotSet)
  383. (
  384. IN VSS_ID SnapshotSetId
  385. ) = 0;
  386. STDMETHOD(GetSnapshotProperties)
  387. (
  388. IN VSS_ID SnapshotId,
  389. OUT VSS_SNAPSHOT_PROP *pProp
  390. ) = 0;
  391. STDMETHOD(Query)
  392. (
  393. IN VSS_ID QueriedObjectId,
  394. IN VSS_OBJECT_TYPE eQueriedObjectType,
  395. IN VSS_OBJECT_TYPE eReturnedObjectsType,
  396. IN IVssEnumObject **ppEnum
  397. ) = 0;
  398. STDMETHOD(IsVolumeSupported)
  399. (
  400. IN VSS_ID ProviderId,
  401. IN VSS_PWSZ pwszVolumeName,
  402. IN BOOL * pbSupportedByThisProvider
  403. ) = 0;
  404. STDMETHOD(DisableWriterClasses)
  405. (
  406. IN const VSS_ID *rgWriterClassId,
  407. IN UINT cClassId
  408. ) = 0;
  409. STDMETHOD(EnableWriterClasses)
  410. (
  411. IN const VSS_ID *rgWriterClassId,
  412. IN UINT cClassId
  413. ) = 0;
  414. STDMETHOD(DisableWriterInstances)
  415. (
  416. IN const VSS_ID *rgWriterInstanceId,
  417. IN UINT cInstanceId
  418. ) = 0;
  419. // called to expose a snapshot
  420. STDMETHOD(ExposeSnapshot)
  421. (
  422. IN VSS_ID SnapshotId,
  423. IN VSS_PWSZ wszPathFromRoot,
  424. IN LONG lAttributes,
  425. IN VSS_PWSZ wszExpose,
  426. OUT VSS_PWSZ *pwszExposed
  427. ) = 0;
  428. STDMETHOD(RevertToSnapshot)
  429. (
  430. IN VSS_ID SnapshotId,
  431. IN BOOL bForceDismount
  432. ) = 0;
  433. STDMETHOD(QueryRevertStatus)
  434. (
  435. IN VSS_PWSZ pwszVolume,
  436. OUT IVssAsync **ppAsync
  437. ) = 0;
  438. };
  439. __declspec(dllexport) HRESULT STDAPICALLTYPE CreateVssBackupComponents(
  440. OUT IVssBackupComponents **ppBackup
  441. );
  442. __declspec(dllexport) HRESULT STDAPICALLTYPE CreateVssExamineWriterMetadata (
  443. IN BSTR bstrXML,
  444. OUT IVssExamineWriterMetadata **ppMetadata
  445. );
  446. #define VSS_SW_BOOTABLE_STATE (1 << 0)
  447. __declspec(dllexport) HRESULT APIENTRY SimulateSnapshotFreeze (
  448. IN GUID guidSnapshotSetId,
  449. IN ULONG ulOptionFlags,
  450. IN ULONG ulVolumeCount,
  451. IN LPWSTR *ppwszVolumeNamesArray,
  452. OUT IVssAsync **ppAsync
  453. );
  454. __declspec(dllexport) HRESULT APIENTRY SimulateSnapshotThaw(
  455. IN GUID guidSnapshotSetId
  456. );
  457. __declspec(dllexport) HRESULT APIENTRY IsVolumeSnapshotted(
  458. IN VSS_PWSZ pwszVolumeName,
  459. OUT BOOL *pbSnapshotsPresent,
  460. OUT LONG *plSnapshotCapability
  461. );
  462. /////////////////////////////////////////////////////////////////////
  463. // Life-management methods for structure members
  464. __declspec(dllexport) void APIENTRY VssFreeSnapshotProperties(
  465. IN VSS_SNAPSHOT_PROP* pProp
  466. );
  467. ///
  468. #endif // _VSBACKUP_H_