From: James Harper Date: Sun, 29 Mar 2009 10:09:04 +0000 (+0000) Subject: Updated Exchange plugin to support accurate mode X-Git-Tag: Release-3.0.0~65 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f68978f6091126dce6856efff2c32558a8c28b7d;p=bacula%2Fbacula Updated Exchange plugin to support accurate mode git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8638 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/win32/filed/plugins/dbi_node.c b/bacula/src/win32/filed/plugins/dbi_node.c index d00ac2f043..91ba09aa03 100644 --- a/bacula/src/win32/filed/plugins/dbi_node.c +++ b/bacula/src/win32/filed/plugins/dbi_node.c @@ -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 diff --git a/bacula/src/win32/filed/plugins/exchange-fd.c b/bacula/src/win32/filed/plugins/exchange-fd.c index 6ea5291557..897c759423 100644 --- a/bacula/src/win32/filed/plugins/exchange-fd.c +++ b/bacula/src/win32/filed/plugins/exchange-fd.c @@ -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; diff --git a/bacula/src/win32/filed/plugins/exchange-fd.h b/bacula/src/win32/filed/plugins/exchange-fd.h index aca569cc33..e1125b2355 100644 --- a/bacula/src/win32/filed/plugins/exchange-fd.h +++ b/bacula/src/win32/filed/plugins/exchange-fd.h @@ -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) diff --git a/bacula/src/win32/filed/plugins/file_node.c b/bacula/src/win32/filed/plugins/file_node.c index a200faf1cf..bd40036290 100644 --- a/bacula/src/win32/filed/plugins/file_node.c +++ b/bacula/src/win32/filed/plugins/file_node.c @@ -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 diff --git a/bacula/src/win32/filed/plugins/storage_group_node.c b/bacula/src/win32/filed/plugins/storage_group_node.c index f87a446851..21badc0ff4 100644 --- a/bacula/src/win32/filed/plugins/storage_group_node.c +++ b/bacula/src/win32/filed/plugins/storage_group_node.c @@ -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) diff --git a/bacula/src/win32/filed/plugins/store_node.c b/bacula/src/win32/filed/plugins/store_node.c index 0b8f538229..ae44939d57 100644 --- a/bacula/src/win32/filed/plugins/store_node.c +++ b/bacula/src/win32/filed/plugins/store_node.c @@ -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; }