Source code of Windows XP (NT5)
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.

522 lines
12 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. UINT cFileCount; // # of files in file group
  36. UINT cDatabases; // # of database files
  37. UINT cLogFiles; // # of log files
  38. } VSS_COMPONENTINFO;
  39. typedef const VSS_COMPONENTINFO *PVSSCOMPONENTINFO;
  40. // component information
  41. class IVssWMComponent : public IUnknown
  42. {
  43. public:
  44. // get component information
  45. STDMETHOD(GetComponentInfo)(PVSSCOMPONENTINFO *ppInfo) = 0;
  46. // free component information
  47. STDMETHOD(FreeComponentInfo)(PVSSCOMPONENTINFO pInfo) = 0;
  48. // obtain a specific file in a file group
  49. STDMETHOD(GetFile)
  50. (
  51. IN UINT iFile,
  52. OUT IVssWMFiledesc **ppFiledesc
  53. ) = 0;
  54. // obtain a specific physical database file for a database
  55. STDMETHOD(GetDatabaseFile)
  56. (
  57. IN UINT iDBFile,
  58. OUT IVssWMFiledesc **ppFiledesc
  59. ) = 0;
  60. // obtain a specific physical log file for a database
  61. STDMETHOD(GetDatabaseLogFile)
  62. (
  63. IN UINT iDbLogFile,
  64. OUT IVssWMFiledesc **ppFiledesc
  65. ) = 0;
  66. };
  67. // interface to examine writer metadata
  68. class IVssExamineWriterMetadata : public IUnknown
  69. {
  70. public:
  71. // obtain identity of the writer
  72. STDMETHOD(GetIdentity)
  73. (
  74. OUT VSS_ID *pidInstance,
  75. OUT VSS_ID *pidWriter,
  76. OUT BSTR *pbstrWriterName,
  77. OUT VSS_USAGE_TYPE *pUsage,
  78. OUT VSS_SOURCE_TYPE *pSource
  79. ) = 0;
  80. // obtain number of include files, exclude files, and components
  81. STDMETHOD(GetFileCounts)
  82. (
  83. OUT UINT *pcIncludeFiles,
  84. OUT UINT *pcExcludeFiles,
  85. OUT UINT *pcComponents
  86. ) = 0;
  87. // obtain specific include files
  88. STDMETHOD(GetIncludeFile)
  89. (
  90. IN UINT iFile,
  91. OUT IVssWMFiledesc **ppFiledesc
  92. ) = 0;
  93. // obtain specific exclude files
  94. STDMETHOD(GetExcludeFile)
  95. (
  96. IN UINT iFile,
  97. OUT IVssWMFiledesc **ppFiledesc
  98. ) = 0;
  99. // obtain specific component
  100. STDMETHOD(GetComponent)
  101. (
  102. IN UINT iComponent,
  103. OUT IVssWMComponent **ppComponent
  104. ) = 0;
  105. // obtain restoration method
  106. STDMETHOD(GetRestoreMethod)
  107. (
  108. OUT VSS_RESTOREMETHOD_ENUM *pMethod,
  109. OUT BSTR *pbstrService,
  110. OUT BSTR *pbstrUserProcedure,
  111. OUT VSS_WRITERRESTORE_ENUM *pwriterRestore,
  112. OUT bool *pbRebootRequired,
  113. UINT *pcMappings
  114. ) = 0;
  115. // obtain a specific alternative location mapping
  116. STDMETHOD(GetAlternateLocationMapping)
  117. (
  118. IN UINT iMapping,
  119. OUT IVssWMFiledesc **ppFiledesc
  120. ) = 0;
  121. // obtain reference to actual XML document
  122. STDMETHOD(GetDocument)(IXMLDOMDocument **pDoc) = 0;
  123. // convert document to a XML string
  124. STDMETHOD(SaveAsXML)(BSTR *pbstrXML) = 0;
  125. // load document from an XML string
  126. STDMETHOD(LoadFromXML)(BSTR bstrXML) = 0;
  127. };
  128. class IVssWriterComponentsExt :
  129. public IVssWriterComponents,
  130. public IUnknown
  131. {
  132. };
  133. // backup components interface
  134. class IVssBackupComponents : public IUnknown
  135. {
  136. public:
  137. // get count of writer components
  138. STDMETHOD(GetWriterComponentsCount)(OUT UINT *pcComponents) = 0;
  139. // obtain a specific writer component
  140. STDMETHOD(GetWriterComponents)
  141. (
  142. IN UINT iWriter,
  143. OUT IVssWriterComponentsExt **ppWriter
  144. ) = 0;
  145. // initialize and create BACKUP_COMPONENTS document
  146. STDMETHOD(InitializeForBackup)(IN BSTR bstrXML = NULL) = 0;
  147. // set state describing backup
  148. STDMETHOD(SetBackupState)
  149. (
  150. IN bool bSelectComponents,
  151. IN bool bBackupBootableSystemState,
  152. IN VSS_BACKUP_TYPE backupType,
  153. IN bool bPartialFileSupport = false
  154. ) = 0;
  155. STDMETHOD(InitializeForRestore)(IN BSTR bstrXML) = 0;
  156. // gather writer metadata
  157. STDMETHOD(GatherWriterMetadata)
  158. (
  159. OUT IVssAsync **pAsync
  160. ) = 0;
  161. // get count of writers with metadata
  162. STDMETHOD(GetWriterMetadataCount)
  163. (
  164. OUT UINT *pcWriters
  165. ) = 0;
  166. // get writer metadata for a specific writer
  167. STDMETHOD(GetWriterMetadata)
  168. (
  169. IN UINT iWriter,
  170. OUT VSS_ID *pidInstance,
  171. OUT IVssExamineWriterMetadata **ppMetadata
  172. ) = 0;
  173. // free writer metadata
  174. STDMETHOD(FreeWriterMetadata)() = 0;
  175. // add a component to the BACKUP_COMPONENTS document
  176. STDMETHOD(AddComponent)
  177. (
  178. IN VSS_ID instanceId,
  179. IN VSS_ID writerId,
  180. IN VSS_COMPONENT_TYPE ct,
  181. IN LPCWSTR wszLogicalPath,
  182. IN LPCWSTR wszComponentName
  183. ) = 0;
  184. // dispatch PrepareForBackup event to writers
  185. STDMETHOD(PrepareForBackup)
  186. (
  187. OUT IVssAsync **ppAsync
  188. ) = 0;
  189. // abort the backup
  190. STDMETHOD(AbortBackup)() = 0;
  191. // dispatch the Identify event so writers can expose their metadata
  192. STDMETHOD(GatherWriterStatus)
  193. (
  194. OUT IVssAsync **pAsync
  195. ) = 0;
  196. // get count of writers with status
  197. STDMETHOD(GetWriterStatusCount)
  198. (
  199. OUT UINT *pcWriters
  200. ) = 0;
  201. STDMETHOD(FreeWriterStatus)() = 0;
  202. STDMETHOD(GetWriterStatus)
  203. (
  204. IN UINT iWriter,
  205. OUT VSS_ID *pidInstance,
  206. OUT VSS_ID *pidWriter,
  207. OUT BSTR *pbstrWriter,
  208. OUT VSS_WRITER_STATE *pnStatus,
  209. OUT HRESULT *phResultFailure
  210. ) = 0;
  211. // indicate whether backup succeeded on a component
  212. STDMETHOD(SetBackupSucceeded)
  213. (
  214. IN VSS_ID instanceId,
  215. IN VSS_ID writerId,
  216. IN VSS_COMPONENT_TYPE ct,
  217. IN LPCWSTR wszLogicalPath,
  218. IN LPCWSTR wszComponentName,
  219. IN bool bSucceded
  220. ) = 0;
  221. // set backup options for the writer
  222. STDMETHOD(SetBackupOptions)
  223. (
  224. IN VSS_ID writerId,
  225. IN VSS_COMPONENT_TYPE ct,
  226. IN LPCWSTR wszLogicalPath,
  227. IN LPCWSTR wszComponentName,
  228. IN LPCWSTR wszBackupOptions
  229. ) = 0;
  230. // indicate that a given component is selected to be restored
  231. STDMETHOD(SetSelectedForRestore)
  232. (
  233. IN VSS_ID writerId,
  234. IN VSS_COMPONENT_TYPE ct,
  235. IN LPCWSTR wszLogicalPath,
  236. IN LPCWSTR wszComponentName,
  237. IN bool bSelectedForRestore
  238. ) = 0;
  239. // set restore options for the writer
  240. STDMETHOD(SetRestoreOptions)
  241. (
  242. IN VSS_ID writerId,
  243. IN VSS_COMPONENT_TYPE ct,
  244. IN LPCWSTR wszLogicalPath,
  245. IN LPCWSTR wszComponentName,
  246. IN LPCWSTR wszRestoreOptions
  247. ) = 0;
  248. // indicate that additional restores will follow
  249. STDMETHOD(SetAdditionalRestores)
  250. (
  251. IN VSS_ID writerId,
  252. IN VSS_COMPONENT_TYPE ct,
  253. IN LPCWSTR wszLogicalPath,
  254. IN LPCWSTR wszComponentName,
  255. IN bool bAdditionalRestores
  256. ) = 0;
  257. // set the backup stamp that the differential or incremental
  258. // backup is based on
  259. STDMETHOD(SetPreviousBackupStamp)
  260. (
  261. IN VSS_ID writerId,
  262. IN VSS_COMPONENT_TYPE ct,
  263. IN LPCWSTR wszLogicalPath,
  264. IN LPCWSTR wszComponentName,
  265. IN LPCWSTR wszPreviousBackupStamp
  266. ) = 0;
  267. // save BACKUP_COMPONENTS document as XML string
  268. STDMETHOD(SaveAsXML)(BSTR *pbstrXML) = 0;
  269. // signal BackupComplete event to the writers
  270. STDMETHOD(BackupComplete)(OUT IVssAsync **ppAsync) = 0;
  271. // add an alternate mapping on restore
  272. STDMETHOD(AddAlternativeLocationMapping)
  273. (
  274. IN VSS_ID writerId,
  275. IN VSS_COMPONENT_TYPE componentType,
  276. IN LPCWSTR wszLogicalPath,
  277. IN LPCWSTR wszComponentName,
  278. IN LPCWSTR wszPath,
  279. IN LPCWSTR wszFilespec,
  280. IN bool bRecursive,
  281. IN LPCWSTR wszDestination
  282. ) = 0;
  283. // add a subcomponent to be restored
  284. STDMETHOD(AddRestoreSubcomponent)
  285. (
  286. IN VSS_ID writerId,
  287. IN VSS_COMPONENT_TYPE componentType,
  288. IN LPCWSTR wszLogicalPath,
  289. IN LPCWSTR wszComponentName,
  290. IN LPCWSTR wszSubComponentLogicalPath,
  291. IN LPCWSTR wszSubComponentName,
  292. IN bool bRepair
  293. ) = 0;
  294. // requestor indicates whether files were successfully restored
  295. STDMETHOD(SetFileRestoreStatus)
  296. (
  297. IN VSS_ID writerId,
  298. IN VSS_COMPONENT_TYPE ct,
  299. IN LPCWSTR wszLogicalPath,
  300. IN LPCWSTR wszComponentName,
  301. IN VSS_FILE_RESTORE_STATUS status
  302. ) = 0;
  303. // signal PreRestore event to the writers
  304. STDMETHOD(PreRestore)(OUT IVssAsync **ppAsync) = 0;
  305. // signal PostRestore event to the writers
  306. STDMETHOD(PostRestore)(OUT IVssAsync **ppAsync) = 0;
  307. // Called to set the context for subsequent snapshot-related operations
  308. STDMETHOD(SetContext)
  309. (
  310. IN LONG lContext
  311. ) = 0;
  312. // start a snapshot set
  313. STDMETHOD(StartSnapshotSet)
  314. (
  315. OUT VSS_ID *pSnapshotSetId
  316. ) = 0;
  317. // add a volume to a snapshot set
  318. STDMETHOD(AddToSnapshotSet)
  319. (
  320. IN VSS_PWSZ pwszVolumeName,
  321. IN VSS_ID ProviderId,
  322. OUT VSS_ID *pidSnapshot
  323. ) = 0;
  324. // create the snapshot set
  325. STDMETHOD(DoSnapshotSet)
  326. (
  327. OUT IVssAsync** ppAsync
  328. ) = 0;
  329. STDMETHOD(DeleteSnapshots)
  330. (
  331. IN VSS_ID SourceObjectId,
  332. IN VSS_OBJECT_TYPE eSourceObjectType,
  333. IN BOOL bForceDelete,
  334. IN LONG* plDeletedSnapshots,
  335. IN VSS_ID* pNondeletedSnapshotID
  336. ) = 0;
  337. STDMETHOD(ImportSnapshots)
  338. (
  339. OUT IVssAsync** ppAsync
  340. ) = 0;
  341. STDMETHOD(RemountReadWrite)
  342. (
  343. IN VSS_ID SnapshotId,
  344. OUT IVssAsync** pAsync
  345. ) = 0;
  346. STDMETHOD(BreakSnapshotSet)
  347. (
  348. IN VSS_ID SnapshotSetId
  349. ) = 0;
  350. STDMETHOD(GetSnapshotProperties)
  351. (
  352. IN VSS_ID SnapshotId,
  353. OUT VSS_SNAPSHOT_PROP *pProp
  354. ) = 0;
  355. STDMETHOD(Query)
  356. (
  357. IN VSS_ID QueriedObjectId,
  358. IN VSS_OBJECT_TYPE eQueriedObjectType,
  359. IN VSS_OBJECT_TYPE eReturnedObjectsType,
  360. IN IVssEnumObject **ppEnum
  361. ) = 0;
  362. STDMETHOD(IsVolumeSupported)
  363. (
  364. IN VSS_ID ProviderId,
  365. IN VSS_PWSZ pwszVolumeName,
  366. IN BOOL * pbSupportedByThisProvider
  367. ) = 0;
  368. STDMETHOD(DisableWriterClasses)
  369. (
  370. IN const VSS_ID *rgWriterClassId,
  371. IN UINT cClassId
  372. ) = 0;
  373. STDMETHOD(EnableWriterClasses)
  374. (
  375. IN const VSS_ID *rgWriterClassId,
  376. IN UINT cClassId
  377. ) = 0;
  378. STDMETHOD(DisableWriterInstances)
  379. (
  380. IN const VSS_ID *rgWriterInstanceId,
  381. IN UINT cInstanceId
  382. ) = 0;
  383. // called to expose a snapshot
  384. STDMETHOD(ExposeSnapshot)
  385. (
  386. IN VSS_ID SnapshotId,
  387. IN VSS_PWSZ wszPathFromRoot,
  388. IN LONG lAttributes,
  389. IN VSS_PWSZ wszExpose,
  390. OUT VSS_PWSZ *pwszExposed
  391. ) = 0;
  392. };
  393. __declspec(dllexport) HRESULT STDAPICALLTYPE CreateVssBackupComponents(
  394. OUT IVssBackupComponents **ppBackup
  395. );
  396. __declspec(dllexport) HRESULT STDAPICALLTYPE CreateVssExamineWriterMetadata (
  397. IN BSTR bstrXML,
  398. OUT IVssExamineWriterMetadata **ppMetadata
  399. );
  400. #define VSS_SW_BOOTABLE_STATE (1 << 0)
  401. __declspec(dllexport) HRESULT APIENTRY SimulateSnapshotFreeze (
  402. IN GUID guidSnapshotSetId,
  403. IN ULONG ulOptionFlags,
  404. IN ULONG ulVolumeCount,
  405. IN LPWSTR *ppwszVolumeNamesArray,
  406. OUT IVssAsync **ppAsync
  407. );
  408. __declspec(dllexport) HRESULT APIENTRY SimulateSnapshotThaw(
  409. IN GUID guidSnapshotSetId
  410. );
  411. __declspec(dllexport) HRESULT APIENTRY IsVolumeSnapshotted(
  412. IN VSS_PWSZ pwszVolumeName,
  413. OUT BOOL *pbSnapshotsPresent,
  414. OUT LONG *plSnapshotCapability
  415. );
  416. /////////////////////////////////////////////////////////////////////
  417. // Life-management methods for structure members
  418. __declspec(dllexport) void APIENTRY VssFreeSnapshotProperties(
  419. IN VSS_SNAPSHOT_PROP* pProp
  420. );
  421. ///
  422. #endif // _VSBACKUP_H_