Skip to content

Commit

Permalink
vss: Fix IVssBackupComponents::SetBackupState call
Browse files Browse the repository at this point in the history
We currently always call the IVssBackupComponents::SetBackupState method
with the arguments bSelectComponents and bBackupBootableSystemState set
to true. This indicates that we do a backup or restore operation in
component mode and that a bootable system state backup is being
performed. This is not really true until we fully implement the whole
VSS API in a new dedicated VSS plugin. As such this patch adds a new
event bEventVssSetBackupState which is raised when normally a
IVssBackupComponents::SetBackupState call is done the plugin can
register this event and implement its own call to
IVssBackupComponents::SetBackupState with the options it want to set and
return an bRC_Skip to let the core not call the method.

This patch also adds a new event named bEventVssPrepareForBackup which is
raised just before a call to IVssBackupComponents::PrepareForBackup is
done.

Fixes #562: VSS Plugin is missing method
            IVssBackupComponents::SetBackupSucceeded
  • Loading branch information
Marco van Wieringen committed Jun 15, 2016
1 parent 3ae6aa7 commit 8b1c713
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 39 deletions.
16 changes: 9 additions & 7 deletions src/filed/fd_plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,15 @@ typedef enum {
bEventNewPluginOptions = 20,
bEventVssInitializeForBackup = 21,
bEventVssInitializeForRestore = 22,
bEventVssBackupAddComponents = 23,
bEventVssPrepareSnapshot = 24,
bEventVssCreateSnapshots = 25,
bEventVssRestoreLoadComponentMetadata = 26,
bEventVssRestoreSetComponentsSelected = 27,
bEventVssCloseRestore = 28,
bEventVssBackupComplete = 29
bEventVssSetBackupState = 23,
bEventVssPrepareForBackup = 24,
bEventVssBackupAddComponents = 25,
bEventVssPrepareSnapshot = 26,
bEventVssCreateSnapshots = 27,
bEventVssRestoreLoadComponentMetadata = 28,
bEventVssRestoreSetComponentsSelected = 29,
bEventVssCloseRestore = 30,
bEventVssBackupComplete = 31
} bEventType;

#define FD_NR_EVENTS bEventVssBackupComplete /* keep this updated ! */
Expand Down
16 changes: 9 additions & 7 deletions src/plugins/filed/bareos_fd_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@
bEventNewPluginOptions=20,
bEventVssInitializeForBackup=21,
bEventVssInitializeForRestore=22,
bEventVssBackupAddComponents=23,
bEventVssPrepareSnapshot=24,
bEventVssCreateSnapshots=25,
bEventVssRestoreLoadComponentMetadata=26,
bEventVssRestoreSetComponentsSelected=27,
bEventVssCloseRestore=28,
bEventVssBackupComplete=29
bEventVssSetBackupState=23,
bEventVssPrepareForBackup=24,
bEventVssBackupAddComponents=25,
bEventVssPrepareSnapshot=26,
bEventVssCreateSnapshots=27,
bEventVssRestoreLoadComponentMetadata=28,
bEventVssRestoreSetComponentsSelected=29,
bEventVssCloseRestore=30,
bEventVssBackupComplete=31
)

bIOPS = dict(
Expand Down
61 changes: 36 additions & 25 deletions src/win32/filed/vss_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#include "bareos.h"
#include "jcr.h"
#include "findlib/find.h"
#define FILE_DAEMON 1
#include "fd_plugins.h"

#undef setlocale

Expand Down Expand Up @@ -435,7 +438,6 @@ bool VSSClientGeneric::Initialize(DWORD dwContext, bool bDuringRestore)
VMP_snapshots = 0;
HRESULT hr = S_OK;
CComPtr<IVssAsync> pAsync1;
VSS_BACKUP_TYPE backup_type;
IVssBackupComponents *pVssObj = (IVssBackupComponents *)m_pVssObject;

if (!(m_CreateVssBackupComponents && m_VssFreeSnapshotProperties)) {
Expand Down Expand Up @@ -519,32 +521,40 @@ bool VSSClientGeneric::Initialize(DWORD dwContext, bool bDuringRestore)

/*
* 2. SetBackupState
*
* Generate a bEventVssSetBackupState event and if none of the plugins
* give back a bRC_Skip it means this will not be performed by any plugin
* and we should do the generic handling ourself in the core.
*/
switch (m_jcr->getJobLevel()) {
case L_FULL:
backup_type = VSS_BT_FULL;
break;
case L_DIFFERENTIAL:
backup_type = VSS_BT_DIFFERENTIAL;
break;
case L_INCREMENTAL:
backup_type = VSS_BT_INCREMENTAL;
break;
default:
Dmsg1(0, "VSSClientGeneric::Initialize: unknown backup level %d\n", m_jcr->getJobLevel());
backup_type = VSS_BT_FULL;
break;
}
if (generate_plugin_event(m_jcr, bEventVssSetBackupState) != bRC_Skip) {
VSS_BACKUP_TYPE backup_type;

switch (m_jcr->getJobLevel()) {
case L_FULL:
backup_type = VSS_BT_FULL;
break;
case L_DIFFERENTIAL:
backup_type = VSS_BT_DIFFERENTIAL;
break;
case L_INCREMENTAL:
backup_type = VSS_BT_INCREMENTAL;
break;
default:
Dmsg1(0, "VSSClientGeneric::Initialize: unknown backup level %d\n", m_jcr->getJobLevel());
backup_type = VSS_BT_FULL;
break;
}

/*
* FIXME: need to support partial files - make last parameter true when done
*/
hr = pVssObj->SetBackupState(true, true, backup_type, false);
if (FAILED(hr)) {
Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->SetBackupState returned 0x%08X\n", hr);
JmsgVssApiStatus(m_jcr, M_FATAL, hr, "SetBackupState");
errno = b_errno_win32;
return false;
/*
* FIXME: need to support partial files - make last parameter true when done
*/
hr = pVssObj->SetBackupState(false, false, backup_type, false);
if (FAILED(hr)) {
Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->SetBackupState returned 0x%08X\n", hr);
JmsgVssApiStatus(m_jcr, M_FATAL, hr, "SetBackupState");
errno = b_errno_win32;
return false;
}
}

/*
Expand Down Expand Up @@ -771,6 +781,7 @@ bool VSSClientGeneric::CreateSnapshots(char *szDriveLetters, bool onefs_disabled
/*
* PrepareForBackup
*/
generate_plugin_event(m_jcr, bEventVssPrepareSnapshot);
hr = pVssObj->PrepareForBackup(&pAsync1.p);
if (FAILED(hr)) {
JmsgVssApiStatus(m_jcr, M_FATAL, hr, "PrepareForBackup");
Expand Down

0 comments on commit 8b1c713

Please sign in to comment.