#include "bacula.h"
#include "filed.h"
+#ifdef WIN32_VSS
+#include "vss.h"
+#endif
+
extern char my_name[];
extern CLIENT *me; /* our client resource */
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
*/
}
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 */
}
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; i<fileset->include_list.size(); i++) {
+ findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
+
+ /* look through all files and check */
+ for (j=0; j<incexe->name_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()
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);