From: Thorsten Engel Date: Tue, 17 May 2005 14:37:05 +0000 (+0000) Subject: code-extenstions for VSS support on Win32 (preliminary, use #define WIN32_VSS for... X-Git-Tag: Release-1.38.0~445 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1e6878f33bc07969e1eda44b86bfb214f5ccd79a;p=bacula%2Fbacula code-extenstions for VSS support on Win32 (preliminary, use #define WIN32_VSS for testing) git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2055 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 6f0d401ba4..b6c61f34a5 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -29,6 +29,10 @@ #include "bacula.h" #include "filed.h" +#ifdef WIN32_VSS +#include "vss.h" +#endif + extern char my_name[]; extern CLIENT *me; /* our client resource */ @@ -1195,9 +1199,25 @@ static int backup_cmd(JCR *jcr) if (!response(jcr, sd, OK_data, "Append Data")) { goto cleanup; } - + generate_daemon_event(jcr, "JobStart"); +#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]); + } + } +#endif + /* * Send Files to Storage daemon */ @@ -1252,11 +1272,17 @@ static int backup_cmd(JCR *jcr) } cleanup: +#ifdef WIN32_VSS + /* tell vss to close the backup session */ + g_VSSClient.CloseBackup(); +#endif + bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles, edit_uint64(jcr->ReadBytes, ed1), edit_uint64(jcr->JobBytes, ed2), jcr->Errors); Dmsg1(110, "End FD msg: %s\n", dir->msg); + /* STOP VSS ON WIN 32 */ return 0; /* return and stop command loop */ } diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index 3bb0d755a7..d38034b475 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -94,6 +94,55 @@ set_find_options(FF_PKT *ff, int incremental, time_t save_time) Dmsg0(100, "Leave set_find_options()\n"); } +/* + * For VSS we need to know which windows drives + * are used, because we create a snapshot of all used + * drives before operation + * + * the function returns the number of used drives and + * fills "drives" with up to 26 (A..Z) drive names + * + */ +int +get_win32_driveletters(FF_PKT *ff, char* szDrives) +{ + /* szDrives must be at least 27 bytes long */ + +#ifndef WIN32 + return 0; +#endif + + szDrives[0] = 0; /* make empty */ + int nCount = 0; + + findFILESET *fileset = ff->fileset; + if (fileset) { + int i, j; + + for (i=0; iinclude_list.size(); i++) { + findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i); + + /* look through all files and check */ + for (j=0; jname_list.size(); j++) { + char *fname = (char *)incexe->name_list.get(j); + /* fname should match x:/ */ + if (strlen (fname) > 3 && B_ISALPHA (fname[0]) + && fname[1] == ':' && fname[2] == '/') { + + /* always add in uppercase */ + char ch = toupper(fname[0]); + /* if not found in string, add drive letter */ + if (!strchr(szDrives,ch)) { + szDrives[nCount] = ch; + szDrives[nCount+1] = 0; + nCount++; + } + } + } + } + } + return nCount; +} /* * Find all specified files (determined by calls to name_add() diff --git a/bacula/src/findlib/protos.h b/bacula/src/findlib/protos.h index 58a2549865..0c2837ecbe 100644 --- a/bacula/src/findlib/protos.h +++ b/bacula/src/findlib/protos.h @@ -39,6 +39,7 @@ void set_find_options(FF_PKT *ff, int incremental, time_t mtime); int find_files(JCR *jcr, FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt, bool), void *pkt); int match_files(JCR *jcr, FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt, bool), void *pkt); int term_find_files(FF_PKT *ff); +int get_win32_driveletters(FF_PKT *ff, char* szDrives); /* From match.c */ void init_include_exclude_files(FF_PKT *ff);