]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
filed: Add support for Object Management
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Wed, 9 Sep 2020 15:21:50 +0000 (17:21 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:57 +0000 (09:02 +0100)
bacula/src/filed/backup.c
bacula/src/filed/fd_plugins.c
bacula/src/filed/fd_plugins.h

index 638f27fce57ec30591f588625bd7071b7bf848f5..81126dadda3ccc41aaade6ec081acf71baf8ce36 100644 (file)
@@ -819,6 +819,7 @@ bool process_and_send_data(bctx_t &bctx)
 
    /* Debug code: check if we must hangup or blowup */
    if (handle_hangup_blowup(jcr, 0, jcr->ReadBytes)) {
+      sd->close();
       goto err;
    }
 
@@ -1069,14 +1070,38 @@ bool encode_and_send_attributes(bctx_t &bctx)
       }
       break;
    case FT_PLUGIN_OBJECT:
-      sd->msglen = Mmsg(sd->msg, "%d %d %d %s %s %s %s %s %s %s %llu",
-                        jcr->JobFiles, ff_pkt->type, ff_pkt->plugin_obj.JobId, ff_pkt->plugin_obj.path,
-                        ff_pkt->plugin_obj.filename,
-                        ff_pkt->plugin_obj.plugin_name, ff_pkt->plugin_obj.object_type,
-                        ff_pkt->plugin_obj.object_name, ff_pkt->plugin_obj.object_source,
-                        ff_pkt->plugin_obj.object_uuid, ff_pkt->plugin_obj.object_size);
-      stat = sd->send();
-      break;
+      {
+         POOL_MEM path;
+         POOL_MEM plugin_name;
+         POOL_MEM object_category;
+         POOL_MEM object_type;
+         POOL_MEM object_name;
+         POOL_MEM object_source;
+         POOL_MEM object_uuid;
+
+         pm_strcpy(path, ff_pkt->plugin_obj.path);
+         bash_spaces(path.c_str());
+         pm_strcpy(plugin_name, ff_pkt->plugin_obj.plugin_name);
+         bash_spaces(plugin_name.c_str());
+         pm_strcpy(object_type, ff_pkt->plugin_obj.object_type);
+         bash_spaces(object_type.c_str());
+         pm_strcpy(object_category, ff_pkt->plugin_obj.object_category);
+         bash_spaces(object_category.c_str());
+         pm_strcpy(object_name, ff_pkt->plugin_obj.object_name);
+         bash_spaces(object_name.c_str());
+         pm_strcpy(object_source, ff_pkt->plugin_obj.object_source);
+         bash_spaces(object_source.c_str());
+         pm_strcpy(object_uuid, ff_pkt->plugin_obj.object_uuid);
+         bash_spaces(object_uuid.c_str());
+
+         sd->msglen = Mmsg(sd->msg, "%s %s %s %s %s %s %s %llu",
+                           path.c_str(), plugin_name.c_str(), object_category.c_str(), object_type.c_str(),
+                           object_name.c_str(), object_source.c_str(), object_uuid.c_str(),
+                           ff_pkt->plugin_obj.object_size);
+         stat = sd->send();
+
+         break;
+      }
    case FT_REG:
       stat = sd->fsend("%ld %d %s%c%s%c%c%s%c%d%c", jcr->JobFiles,
                ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0, attribsEx, 0,
index 979ee49d4fbcf1071eb9e7195ebb13bcdcb4e39d..9e00d2325cba2a0a37b850740dd159b951ab00c8 100644 (file)
@@ -686,10 +686,9 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
             }
             ff_pkt->fname = cmd;                 /* full plugin string */
             if (sp.type == FT_PLUGIN_OBJECT) {
-               ff_pkt->plugin_obj.JobId = jcr->JobId;
                ff_pkt->plugin_obj.path = sp.plugin_obj.path;
-               ff_pkt->plugin_obj.filename = sp.plugin_obj.filename;
-               ff_pkt->plugin_obj.plugin_name = sp.plugin_obj.plugin_name;
+               ff_pkt->plugin_obj.plugin_name = cmd;
+               ff_pkt->plugin_obj.object_category = sp.plugin_obj.object_category;
                ff_pkt->plugin_obj.object_type = sp.plugin_obj.object_type;
                ff_pkt->plugin_obj.object_name = sp.plugin_obj.object_name;
                ff_pkt->plugin_obj.object_source = sp.plugin_obj.object_source;
index 39e370d7dd02df5c3c80bffdc7196b5c8eff16e5..3dc8dbcd6e363d0c998ce7c187bca7eeb130d7f6 100644 (file)
@@ -92,22 +92,25 @@ struct stream_pkt {
 };
 
 struct restore_object {
-   const 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 */
-   int32_t object_compression;              /* set to compression type */
+   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 */
+   int32_t object_compression;        /* set to compression type */
 };
 
+/* Types of plugin objects */
+//TODO probably more specific db types needed
+#define PLUGIN_OBJECT_DATABASE "database" /* For all database plugins */
+
 struct plugin_object {
-   uint32_t JobId;
-   const char *path;
-   const char *filename;
-   const char *plugin_name;
-   const char *object_type;
-   const char *object_name;
-   const char *object_source;
-   const char *object_uuid;
+   char *path;
+   char *plugin_name;
+   char *object_category;
+   char *object_type;
+   char *object_name;
+   char *object_source;
+   char *object_uuid;
    uint64_t object_size;
 };