From ce2be7f7adaad424dd4d3198864dcfe84e9f9919 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 14 Apr 2010 12:44:43 +0200 Subject: [PATCH] Add vss_close_backup_session after find_files + add object_name to restore object --- bacula/src/filed/backup.c | 24 ++++++++++++++++++++++++ bacula/src/filed/fd_plugins.c | 26 ++++++++++++++++++++------ bacula/src/filed/fd_plugins.h | 1 + bacula/src/filed/job.c | 13 ------------- bacula/src/plugins/fd/test-plugin-fd.c | 2 +- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 580dd7d4c8..3456446064 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -61,6 +61,7 @@ bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_stream); static bool crypto_session_start(JCR *jcr); static void crypto_session_end(JCR *jcr); static bool crypto_session_send(JCR *jcr, BSOCK *sd); +static void close_vss_backup_session(JCR *jcr); /** * Find all the requested files and send them @@ -172,6 +173,8 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) jcr->xattr_data->nr_errors); } + close_vss_backup_session(jcr); + accurate_finish(jcr); /* send deleted or base file list to SD */ stop_heartbeat_monitor(jcr); @@ -1317,3 +1320,24 @@ void unstrip_path(FF_PKT *ff_pkt) sm_check(__FILE__, __LINE__, true); } } + +static void close_vss_backup_session(JCR *jcr) +{ +#if defined(WIN32_VSS) + /* STOP VSS ON WIN32 */ + /* tell vss to close the backup session */ + if (jcr->VSS) { + if (g_pVSSClient->CloseBackup()) { + /* inform user about writer states */ + for (int i=0; i<(int)g_pVSSClient->GetWriterCount(); i++) { + int msg_type = M_INFO; + if (g_pVSSClient->GetWriterState(i) < 1) { + msg_type = M_WARNING; + jcr->JobErrors++; + } + Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), g_pVSSClient->GetWriterInfo(i)); + } + } + } +#endif +} diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 4f4f93a90d..8e100671f0 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -276,8 +276,8 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) if (plug_func(plugin)->startBackupFile(jcr->plugin_ctx, &sp) != bRC_OK) { goto bail_out; } - if (sp.type == 0 || sp.fname == NULL) { - Jmsg1(jcr, M_FATAL, 0, _("Command plugin \"%s\" returned bad startBackupFile packet.\n"), + if (sp.type == 0) { + Jmsg1(jcr, M_FATAL, 0, _("Command plugin \"%s\": no type in startBackupFile packet.\n"), cmd); goto bail_out; } @@ -287,16 +287,30 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) * Copy fname and link because save_file() zaps them. This * avoids zaping the plugin's strings. */ - pm_strcpy(fname, sp.fname); - pm_strcpy(link, sp.link); - ff_pkt->fname = fname.c_str(); - ff_pkt->link = link.c_str(); ff_pkt->type = sp.type; if (sp.type == FT_RESTORE_FIRST) { + if (!sp.object_name) { + Jmsg1(jcr, M_FATAL, 0, _("Command plugin \"%s\": no object_name in startBackupFile packet.\n"), + cmd); + goto bail_out; + } + pm_strcpy(fname, sp.object_name); + ff_pkt->fname = fname.c_str(); ff_pkt->LinkFI = sp.index; /* restore object index */ ff_pkt->object = sp.object; ff_pkt->object_len = sp.object_len; + } else { + if (!sp.fname) { + Jmsg1(jcr, M_FATAL, 0, _("Command plugin \"%s\": no fname in startBackupFile packet.\n"), + cmd); + goto bail_out; + } + pm_strcpy(fname, sp.fname); + pm_strcpy(link, sp.link); + ff_pkt->fname = fname.c_str(); + ff_pkt->link = link.c_str(); } + memcpy(&ff_pkt->statp, &sp.statp, sizeof(ff_pkt->statp)); Dmsg2(dbglvl, "startBackup returned type=%d, fname=%s\n", sp.type, sp.fname); if (sp.object) { diff --git a/bacula/src/filed/fd_plugins.h b/bacula/src/filed/fd_plugins.h index 963451b4b4..adf82df4c5 100644 --- a/bacula/src/filed/fd_plugins.h +++ b/bacula/src/filed/fd_plugins.h @@ -99,6 +99,7 @@ struct save_pkt { uint32_t flags; /* Bacula internal flags */ bool portable; /* set if data format is portable */ char *cmd; /* command */ + char *object_name; /* Object name to create */ char *object; /* restore object data to save */ int32_t object_len; /* restore object length */ int32_t index; /* restore object index */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index b11466128a..c4b203ecd1 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1760,20 +1760,7 @@ static int backup_cmd(JCR *jcr) cleanup: #if defined(WIN32_VSS) - /* STOP VSS ON WIN32 */ - /* tell vss to close the backup session */ if (jcr->VSS) { - if (g_pVSSClient->CloseBackup()) { - /* inform user about writer states */ - for (int i=0; i<(int)g_pVSSClient->GetWriterCount(); i++) { - int msg_type = M_INFO; - if (g_pVSSClient->GetWriterState(i) < 1) { - msg_type = M_WARNING; - jcr->JobErrors++; - } - Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), g_pVSSClient->GetWriterInfo(i)); - } - } Win32ConvCleanupCache(); V(vss_mutex); } diff --git a/bacula/src/plugins/fd/test-plugin-fd.c b/bacula/src/plugins/fd/test-plugin-fd.c index 8a239e8b95..13ccd501fc 100644 --- a/bacula/src/plugins/fd/test-plugin-fd.c +++ b/bacula/src/plugins/fd/test-plugin-fd.c @@ -290,7 +290,7 @@ static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp) return bRC_Error; } time_t now = time(NULL); - sp->fname = (char *)"james.xml"; + sp->object_name = (char *)"james.xml"; sp->object = (char *)"This is test data for the restore object."; sp->object_len = strlen(sp->object); sp->index = 2; -- 2.39.5