From: Kern Sibbald Date: Wed, 14 Apr 2010 13:24:50 +0000 (+0200) Subject: Apply James' patch with my restore object changes X-Git-Tag: Release-7.0.0~1944 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f6eb2a314e51d33cbf482b1273676122280b9f2b;p=bacula%2Fbacula Apply James' patch with my restore object changes --- diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 3456446064..4988b64451 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -1338,6 +1338,14 @@ static void close_vss_backup_session(JCR *jcr) Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), g_pVSSClient->GetWriterInfo(i)); } } + WCHAR *metadata = g_pVSSClient->GetMetadata(); + FF_PKT *ff_pkt = jcr->ff; + ff_pkt->fname = bstrdup("job_metadata.xml"); + ff_pkt->type = FT_RESTORE_FIRST; + ff_pkt->LinkFI = 0; + ff_pkt->object = (char *)metadata; + ff_pkt->object_len = (wcslen(metadata) + 1) * sizeof(WCHAR); + save_file(jcr, ff_pkt, true); } #endif } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 4a224cd68f..9fa5df46cd 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -317,6 +317,7 @@ void *handle_client_request(void *dirp) dir->signal(BNET_TERMINATE); free_plugins(jcr); /* release instantiated plugins */ + free_and_null_pool_memory(jcr->job_metadata); /* Clean up fileset */ FF_PKT *ff = jcr->ff; @@ -619,7 +620,6 @@ static int runscript_cmd(JCR *jcr) return dir->fsend(OKRunScript); } - static int restore_object_cmd(JCR *jcr) { BSOCK *dir = jcr->dir_bsock; @@ -663,8 +663,15 @@ static int restore_object_cmd(JCR *jcr) rop.object = dir->msg; // Dmsg2(000, "Recv Object: len=%d Object=%s\n", dir->msglen, dir->msg); - /* pass to plugin */ - generate_plugin_event(jcr, bEventRestoreObject, (void *)&rop); + if (strcmp(rop.object_name, "job_metadata.xml") == 0) { + Dmsg0(000, "got job metadata\n"); + free_and_null_pool_memory(jcr->job_metadata); + jcr->job_metadata = rop.object; + rop.object = NULL; + } else { + /* pass to plugin */ + generate_plugin_event(jcr, bEventRestoreObject, (void *)&rop); + } if (rop.object_name) { free(rop.object_name); @@ -1958,7 +1965,8 @@ static int restore_cmd(JCR *jcr) #if defined(WIN32_VSS) /* START VSS ON WIN32 */ if (jcr->VSS) { - if (g_pVSSClient->InitializeForRestore(jcr, vss_restore_init_callback)) { + if (g_pVSSClient->InitializeForRestore(jcr, vss_restore_init_callback, + (WCHAR *)jcr->job_metadata)) { /* inform user about writer states */ int i; for (i=0; i < (int)g_pVSSClient->GetWriterCount(); i++) { @@ -1976,6 +1984,7 @@ static int restore_cmd(JCR *jcr) berrno be; Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. ERR=%s\n"), be.bstrerror()); } + free_and_null_pool_memory(jcr->job_metadata); run_scripts(jcr, jcr->RunScripts, "ClientAfterVSS"); } #endif diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 9e6c14a504..9db901ad67 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -358,6 +358,7 @@ public: /* File Daemon specific part of JCR */ uint32_t num_files_examined; /* files examined this job */ POOLMEM *last_fname; /* last file saved/verified */ + POOLMEM *job_metadata; /* VSS job metadata */ acl_data_t *acl_data; /* ACLs for backup/restore */ xattr_data_t *xattr_data; /* Extended Attributes for backup/restore */ int32_t last_type; /* type of last file saved/verified */