From e94e11a8eff9e633607bfc981a086669b37acdc9 Mon Sep 17 00:00:00 2001 From: Thorsten Engel Date: Tue, 24 May 2005 14:25:57 +0000 Subject: [PATCH] improved vss support (goal: only 1 binary, still problems on w2k3, xp seems to work) git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2081 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/job.c | 33 ++++++++++++++++++++++----------- bacula/src/lib/winapi.c | 36 +++++++++++++++++++++++++++++++++++- bacula/src/lib/winapi.h | 4 ++-- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index b6f02c51b9..7d3edd1b8b 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1204,17 +1204,27 @@ static int backup_cmd(JCR *jcr) #ifdef WIN32_VSS /* START VSS ON WIN 32 */ - g_VSSClient.InitializeForBackup(); - /* tell vss which drives to snapshot */ - char szWinDriveLetters[27]; - if (get_win32_driveletters((FF_PKT *)jcr->ff, szWinDriveLetters)) { - Jmsg(jcr, M_INFO, 0, _("Generate VSS snapshots. Drives=%s\n"), szWinDriveLetters); - g_VSSClient.CreateSnapshots(szWinDriveLetters); - - for (int i=0; iInitializeForBackup()) { + /* tell vss which drives to snapshot */ + char szWinDriveLetters[27]; + if (get_win32_driveletters((FF_PKT *)jcr->ff, szWinDriveLetters)) { + Jmsg(jcr, M_INFO, 0, _("Generate VSS snapshots. Driver=%s, Drive(s)=%s\n"), g_pVSSClient->GetDriverName(), szWinDriveLetters); + + if (!g_pVSSClient->CreateSnapshots(szWinDriveLetters)) { + Jmsg(jcr, M_WARNING, 0, _("Generate VSS snapshots failed\n")); + } + else { + for (int i=0; iCloseBackup(); #endif bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles, diff --git a/bacula/src/lib/winapi.c b/bacula/src/lib/winapi.c index b7bf9d613e..0f640a49ad 100644 --- a/bacula/src/lib/winapi.c +++ b/bacula/src/lib/winapi.c @@ -31,8 +31,14 @@ #include "winapi.h" +#ifdef WIN32_VSS +#include "vss.h" +#endif + // init with win9x, but maybe set to NT in InitWinAPI DWORD g_platform_id = VER_PLATFORM_WIN32_WINDOWS; +/* preset VSSClient to NULL */ +VSSClient* g_pVSSClient = NULL; /* API Pointers */ @@ -75,6 +81,14 @@ t_SetCurrentDirectoryW p_SetCurrentDirectoryW = NULL; t_GetCurrentDirectoryA p_GetCurrentDirectoryA = NULL; t_GetCurrentDirectoryW p_GetCurrentDirectoryW = NULL; +#ifdef WIN32_VSS +void +VSSCleanup() +{ + if (g_pVSSClient) + delete (g_pVSSClient); +} +#endif void InitWinAPIWrapper() @@ -162,16 +176,21 @@ InitWinAPIWrapper() } // do we run on win 9x ??? - OSVERSIONINFO osversioninfo; + OSVERSIONINFO osversioninfo; osversioninfo.dwOSVersionInfoSize = sizeof(osversioninfo); + DWORD dwMinorVersion; + // Get the current OS version if (!GetVersionEx(&osversioninfo)) { g_platform_id = 0; + dwMinorVersion = 0; } else { g_platform_id = osversioninfo.dwPlatformId; + dwMinorVersion = osversioninfo.dwMinorVersion; } + /* deinitialize some routines on win95 - they're not implemented well */ if (g_platform_id == VER_PLATFORM_WIN32_WINDOWS) { p_BackupRead = NULL; p_BackupWrite = NULL; @@ -191,5 +210,20 @@ InitWinAPIWrapper() p_wmkdir = NULL; p_wopen = NULL; } + + /* decide which vss class to initialize */ +#ifdef WIN32_VSS + switch (dwMinorVersion) { + case 1: + g_pVSSClient = new VSSClientXP(); + atexit(VSSCleanup); + break; + case 2: + g_pVSSClient = new VSSClient2003(); + atexit(VSSCleanup); + break; + } +#endif } + #endif diff --git a/bacula/src/lib/winapi.h b/bacula/src/lib/winapi.h index ed3580a416..1b815d51d9 100644 --- a/bacula/src/lib/winapi.h +++ b/bacula/src/lib/winapi.h @@ -140,8 +140,8 @@ extern t_GetCurrentDirectoryA p_GetCurrentDirectoryA; extern t_GetCurrentDirectoryW p_GetCurrentDirectoryW; #ifdef WIN32_VSS -class VSSClient; -extern VSSClient g_VSSClient; +class VSSClient; +extern VSSClient* g_pVSSClient; #endif void InitWinAPIWrapper(); -- 2.39.5