#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
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,
#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 */
t_GetCurrentDirectoryA p_GetCurrentDirectoryA = NULL;
t_GetCurrentDirectoryW p_GetCurrentDirectoryW = NULL;
+#ifdef WIN32_VSS
+void
+VSSCleanup()
+{
+ if (g_pVSSClient)
+ delete (g_pVSSClient);
+}
+#endif
void
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;
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