]> git.sur5r.net Git - bacula/bacula/commitdiff
improved vss support (goal: only 1 binary, still problems on w2k3, xp seems to work)
authorThorsten Engel <thorsten.engel@matrix-computer.com>
Tue, 24 May 2005 14:25:57 +0000 (14:25 +0000)
committerThorsten Engel <thorsten.engel@matrix-computer.com>
Tue, 24 May 2005 14:25:57 +0000 (14:25 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2081 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/filed/job.c
bacula/src/lib/winapi.c
bacula/src/lib/winapi.h

index b6f02c51b99ccb70654c627f99b8453c2165dc12..7d3edd1b8b3284671c44c732fea3731d2319bd6e 100644 (file)
@@ -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; i<strlen (szWinDriveLetters); i++) {
-         if (islower(szWinDriveLetters[i]))
-            Jmsg(jcr, M_WARNING, 0, _("Generate VSS snapshot of drive %c: failed\n"), szWinDriveLetters[i]);
+   if (g_pVSSClient) {
+      if (g_pVSSClient->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. 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; i<strlen (szWinDriveLetters); i++) {
+                  if (islower(szWinDriveLetters[i]))
+                     Jmsg(jcr, M_WARNING, 0, _("Generate VSS snapshot of drive %c: failed\n"), szWinDriveLetters[i]);
+               }
+            }
+         }
+      } else {
+         Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled."));
       }
+
    }
 #endif
 
@@ -1274,7 +1284,8 @@ static int backup_cmd(JCR *jcr)
 cleanup:
 #ifdef WIN32_VSS
    /* tell vss to close the backup session */
-   g_VSSClient.CloseBackup();
+   if (g_pVSSClient)
+      g_pVSSClient->CloseBackup();
 #endif
 
    bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
index b7bf9d613ea8e4e3ac2af8ac0872e59c5d8e8e0a..0f640a49adeb3852c7867a1b156943cf4166e3d2 100644 (file)
 
 #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
index ed3580a416484b8153ef4ecee13ef2a0e485b233..1b815d51d9fb8299570965ac1e020c40072e5390 100644 (file)
@@ -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();