]> git.sur5r.net Git - bacula/bacula/commitdiff
Updated Exchange plugin to support accurate mode
authorJames Harper <james.harper@bendigoit.com.au>
Sun, 29 Mar 2009 10:09:04 +0000 (10:09 +0000)
committerJames Harper <james.harper@bendigoit.com.au>
Sun, 29 Mar 2009 10:09:04 +0000 (10:09 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8638 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/win32/filed/plugins/dbi_node.c
bacula/src/win32/filed/plugins/exchange-fd.c
bacula/src/win32/filed/plugins/exchange-fd.h
bacula/src/win32/filed/plugins/file_node.c
bacula/src/win32/filed/plugins/storage_group_node.c
bacula/src/win32/filed/plugins/store_node.c

index d00ac2f043c3907aa4c475bc7e545fedc3fa4370..91ba09aa039a606704ecf42d789342f98cf0061d 100644 (file)
@@ -55,16 +55,22 @@ dbi_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp)
 
         _DebugMessage(100, "startBackupNode_DBI state = %d\n", state);
 
-        sp->fname = full_path;
-        sp->link = full_path;
-        sp->statp.st_mode = 0700 | S_IFREG;
-        sp->statp.st_ctime = now;
-        sp->statp.st_mtime = now;
-        sp->statp.st_atime = now;
-        sp->statp.st_size = (uint64_t)-1;
-        sp->type = FT_REG;
-
-        return bRC_OK;
+        if (context->job_level == 'F') {
+                sp->fname = full_path;
+                sp->link = full_path;
+                       sp->statp.st_mode = 0700 | S_IFREG;
+               sp->statp.st_ctime = now;
+               sp->statp.st_mtime = now;
+               sp->statp.st_atime = now;
+               sp->statp.st_size = (uint64_t)-1;
+               sp->type = FT_REG;
+               return bRC_OK;
+        }
+        else
+        {
+                bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path);
+               return bRC_Seen;
+        }
 }
 
 bRC
index 6ea529155787b3990c0625b0738b6c4b4744d71d..897c759423dfc2104e68693eee3fc21f30669cbe 100644 (file)
@@ -207,6 +207,7 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
         exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext;
         char *name;
         int i, intval;
+        int accurate;
 
         switch (event->eventType) {
         case bEventJobStart:
@@ -217,6 +218,8 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
                 break;
         case bEventStartBackupJob:
                 _DebugMessage(0, "BackupStart\n");
+                bfuncs->getBaculaValue(ctx, bVarAccurate, (void *)&accurate);
+                context->accurate = accurate;
                 context->job_type = JOB_TYPE_BACKUP;
                 // level should have been specified by now - check it
                 // if level is D or I, since should have been specified too
@@ -342,6 +345,8 @@ startBackupFile(bpContext *ctx, struct save_pkt *sp)
         do {
                 current_node  = context->current_node;
                 retval = current_node->startBackupFile(context, sp);
+                if (retval == bRC_Seen)
+                       endBackupFile(ctx);
         } while (current_node != context->current_node);
         _DebugMessage(100, "startBackupFile done - type = %d, fname = %s, retval = %d\n", sp->type, sp->fname, retval);
         return retval;
index aca569cc33e8e7ca10f9b6f670c51ab053f27c7d..e1125b23559247e3f9b856910f4ab7341b47d085 100644 (file)
@@ -76,7 +76,6 @@ enum {
 #define FT_REG        3
 #define FT_DIREND     5
 
-
 #define _REENTRANT    1
 #define _THREAD_SAFE  1
 #define _POSIX_PTHREAD_SEMANTICS 1
@@ -110,7 +109,6 @@ typedef int64_t   boffset_t;
 #include "host.h"
 #endif
 
-
 #define EXCHANGE_PLUGIN_VERSION 1
 
 #define JOB_TYPE_BACKUP 1
@@ -135,6 +133,7 @@ struct exchange_fd_context_t {
         time_t job_since;
         bool notrunconfull_option;
         bool truncate_logs;
+        bool accurate;
 };
 
 static inline char *tocharstring(WCHAR *src)
index a200faf1cf47753a42276ba9dc441f0bde04ee6d..bd40036290bf3ac5308ed277fdc343e58651a487 100644 (file)
@@ -65,17 +65,21 @@ file_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp
         time_t now = time(NULL);
         _DebugMessage(100, "startBackupNode_FILE state = %d\n", state);
 
-        sp->fname = full_path;
-        sp->link = full_path;
-        _DebugMessage(100, "fname = %s\n", sp->fname);
-        sp->statp.st_mode = 0700 | S_IFREG;
-        sp->statp.st_ctime = now;
-        sp->statp.st_mtime = now;
-        sp->statp.st_atime = now;
-        sp->statp.st_size = (uint64_t)-1;
-        sp->type = FT_REG;
-
-        return bRC_OK;
+       if (context->job_level == 'F' || parent->type == NODE_TYPE_STORAGE_GROUP) {
+               sp->fname = full_path;
+               sp->link = full_path;
+               _DebugMessage(100, "fname = %s\n", sp->fname);
+               sp->statp.st_mode = 0700 | S_IFREG;
+               sp->statp.st_ctime = now;
+               sp->statp.st_mtime = now;
+               sp->statp.st_atime = now;
+               sp->statp.st_size = (uint64_t)-1;
+               sp->type = FT_REG;
+               return bRC_OK;
+        } else {
+                bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path);
+               return bRC_Seen;
+        }
 }
 
 bRC
index f87a446851baaae192dbacac57ff0444fea9c817..21badc0ff449871706f3ad60d6fd8639d5e9632f 100644 (file)
@@ -71,19 +71,23 @@ storage_group_node_t::startBackupFile(exchange_fd_context_t *context, struct sav
                         logfile_ptr = NULL;
                         if (context->job_level == 'F')
                         {
-                                _DebugMessage(100, "Calling HrESEBackupSetup\n");
+                                _DebugMessage(100, "Calling HrESEBackupSetup (BACKUP_TYPE_FULL)\n");
                                 result = HrESEBackupSetup(hccx, ibi->hInstanceId, BACKUP_TYPE_FULL);
-                                state = 1;
+                               state = 1;
                         }
                         else
                         {
-                                _DebugMessage(100, "Calling HrESEBackupSetup\n");
+                                _DebugMessage(100, "Calling HrESEBackupSetup (BACKUP_TYPE_LOGS_ONLY)\n");
                                 result = HrESEBackupSetup(hccx, ibi->hInstanceId, BACKUP_TYPE_LOGS_ONLY);
-                                state = 2;
+                               if (context->accurate)
+                                       state = 1;
+                                else
+                                       state = 2;
                         }
                         if (result != 0)
                         {
                                 _JobMessage(M_ERROR, "HrESEBackupSetup failed with error 0x%08x - %s\n", result, ESEErrorMessage(result));
+                                state = 999;
                                 return bRC_Error;
                         }
                         break;
@@ -186,7 +190,14 @@ storage_group_node_t::startBackupFile(exchange_fd_context_t *context, struct sav
                                 }
                                 else
                                 {
-                                        //_DebugMessage(100, "NOT including file %S\n", logfile_ptr);
+                                       if (context->accurate) {
+                                                tmp = new char[strlen(full_path) + wcslen(tmp_logfile_ptr) + 1];
+                                               strcpy(tmp, full_path);
+                                               wcstombs(tmp + strlen(full_path), tmp_logfile_ptr, wcslen(tmp_logfile_ptr) + 1);
+                                                _JobMessage(M_WARNING, "Marking '%s' as seen\n", tmp);
+                                               bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)tmp);
+                                               delete tmp;
+                                        }
                                 }
 
                                 if (handle != INVALID_HANDLE_VALUE)
index 0b8f53822927e2b1062baf87f744986688c78468..ae44939d571547bbbc1292f98c555ddca7074b18 100644 (file)
@@ -75,15 +75,23 @@ store_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *s
                 context->current_node = file_node;
                 break;
         case 3:
-                time_t now = time(NULL);
-                sp->fname = full_path;
-                sp->link = full_path;
-                sp->statp.st_mode = 0700 | S_IFDIR;
-                sp->statp.st_ctime = now;
-                sp->statp.st_mtime = now;
-                sp->statp.st_atime = now;
-                sp->statp.st_size = 0;
-                sp->type = FT_DIREND;
+                if (context->job_level == 'F')
+                {
+                        time_t now = time(NULL);
+                        sp->fname = full_path;
+                        sp->link = full_path;
+                        sp->statp.st_mode = 0700 | S_IFDIR;
+                        sp->statp.st_ctime = now;
+                        sp->statp.st_mtime = now;
+                        sp->statp.st_atime = now;
+                        sp->statp.st_size = 0;
+                        sp->type = FT_DIREND;
+                }
+                else
+                {
+                        bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path);
+                       return bRC_Seen;
+                }
                 break;
         }