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
}
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;
return dir->fsend(OKRunScript);
}
-
static int restore_object_cmd(JCR *jcr)
{
BSOCK *dir = jcr->dir_bsock;
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);
#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++) {
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
/* 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 */
$(OBJDIR)/vss_root_node.o \
$(OBJDIR)/vss_writer_node.o \
$(OBJDIR)/vss_component_node.o \
- $(OBJDIR)/vss_directory_node.o \
- $(OBJDIR)/vss_file_node.o
+ $(OBJDIR)/vss_file_node.o \
+ $(OBJDIR)/find_filespec.o
SYSTEMSTATE_OBJS = \
$(VSS_BASE_OBJS) \
- $(OBJDIR)/systemstate-fd.o
+ $(OBJDIR)/systemstate-fd.o \
+ $(OBJDIR)/systemstate_registry.o \
+ $(OBJDIR)/systemstate_frs.o \
+ $(OBJDIR)/systemstate_complusregdb.o
BPIPE_OBJS = \
$(OBJDIR)/bpipe-fd.o
}
-bool VSSClient::InitializeForRestore(JCR *jcr, bool (*VssInitCallback)(JCR *, int))
+bool VSSClient::InitializeForRestore(JCR *jcr, bool (*VssInitCallback)(JCR *, int), WCHAR *job_metadata)
{
+ m_metadata = job_metadata;
m_jcr = jcr;
return Initialize(0, true/*=>Restore*/, VssInitCallback);
}
// Backup Process
bool InitializeForBackup(JCR *jcr);
- bool InitializeForRestore(JCR *jcr, bool (*VssInitCallback)(JCR *, int) = NULL);
- //bool GatherForRestore() = 0;
- //bool PrepareForRestore() = 0;
+ bool InitializeForRestore(JCR *jcr, bool (*VssInitCallback)(JCR *, int) = NULL, WCHAR *job_metadata = NULL);
virtual bool CreateSnapshots(char* szDriveLetters) = 0;
virtual bool CloseBackup() = 0;
virtual bool CloseRestore() = 0;
+ virtual WCHAR *GetMetadata() = 0;
virtual const char* GetDriverName() = 0;
bool GetShadowPath (const char* szFilePath, char* szShadowPath, int nBuflen);
bool GetShadowPathW (const wchar_t* szFilePath, wchar_t* szShadowPath, int nBuflen); /* nBuflen in characters */
bool m_bCoInitializeSecurityCalled;
bool m_bDuringRestore; /* true if we are doing a restore */
bool m_bBackupIsInitialized;
+
+ WCHAR *m_metadata;
};
class VSSClientXP:public VSSClient
virtual bool CreateSnapshots(char* szDriveLetters);
virtual bool CloseBackup();
virtual bool CloseRestore();
+ virtual WCHAR *GetMetadata();
virtual const char* GetDriverName() { return "VSS WinXP"; };
private:
virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
virtual bool CreateSnapshots(char* szDriveLetters);
virtual bool CloseBackup();
virtual bool CloseRestore();
+ virtual WCHAR *GetMetadata();
virtual const char* GetDriverName() { return "VSS Win 2003"; };
private:
virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
virtual bool CreateSnapshots(char* szDriveLetters);
virtual bool CloseBackup();
virtual bool CloseRestore();
+ virtual WCHAR *GetMetadata();
virtual const char* GetDriverName() { return "VSS Vista"; };
private:
virtual bool Initialize(DWORD dwContext, bool bDuringRestore, bool (*VssInitCallback)(JCR *, int) = NULL);
* Initialize for restore
*/
- WCHAR *xml;
HRESULT hr;
+
+#if 0
+ WCHAR *xml;
int fd;
struct stat stat;
-
/* obviously this is just temporary - the xml should come from somewhere like the catalog */
fd = open("C:\\james.xml", O_RDONLY);
Dmsg1(0, "fd = %d\n", fd);
read(fd, xml, stat.st_size);
close(fd);
xml[stat.st_size / sizeof(WCHAR)] = 0;
+#endif
// 1. InitializeForRestore
- hr = ((IVssBackupComponents*) m_pVssObject)->InitializeForRestore(xml);
+ hr = ((IVssBackupComponents*) m_pVssObject)->InitializeForRestore(m_metadata);
if (FAILED(hr)) {
Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->InitializeForRestore returned 0x%08X\n", hr);
errno = b_errno_win32;
bool VSSClientGeneric::CloseBackup()
{
bool bRet = false;
+ HRESULT hr;
+ BSTR xml;
+
if (!m_pVssObject)
errno = ENOSYS;
else {
m_bBackupIsInitialized = false;
+ hr = pVss->SaveAsXML(&xml);
+ if (hr == ERROR_SUCCESS)
+ m_metadata = xml;
+ else
+ m_metadata = NULL;
+#if 0
{
HRESULT hr;
BSTR xml;
write(fd, xml, wcslen(xml) * sizeof(WCHAR));
close(fd);
}
+#endif
if (SUCCEEDED(pVss->BackupComplete(&pAsync.p))) {
// Waits for the async operation to finish and checks the result
WaitAndCheckForAsyncOperation(pAsync.p);
return bRet;
}
+WCHAR *VSSClientGeneric::GetMetadata()
+{
+ return m_metadata;
+}
+
bool VSSClientGeneric::CloseRestore()
{
HRESULT hr;