]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix Docker Plugin for accurate backup.
authorRadosław Korzeniewski <radekk@inteos.pl>
Wed, 15 Jan 2020 08:47:48 +0000 (09:47 +0100)
committerRadosław Korzeniewski <radekk@inteos.pl>
Wed, 15 Jan 2020 08:47:48 +0000 (09:47 +0100)
bacula/.gitignore
bacula/src/plugins/fd/docker/docker-fd.c
bacula/src/plugins/fd/docker/docker-fd.h

index ffa46b4e9e010e022f0ddf869228e4ddb48b6926..6a3a632a3e0dc810c63d806e40afb5b92192f051 100644 (file)
@@ -6,7 +6,7 @@
 # *.[oa]
 # *~
 
-# 
+#
 *.la
 *.a
 *.o
@@ -389,7 +389,7 @@ src/lib/libbaccfg.a
 src/lib/libbacpy.a
 
 # src/plugins/dir/
-src/plugins/dir/*.o   
+src/plugins/dir/*.o
 src/plugins/dir/*.so
 src/plugins/dir/main
 src/plugins/dir/Makefile
@@ -1305,3 +1305,6 @@ platforms/osx/dl
 platforms/osx/products
 platforms/osx/tools
 TAGS
+src/plugins/fd/docker/baculatar/baculatar-*.docker.tar
+
+.vscode
\ No newline at end of file
index 7082001d4fdea54a7e494983abe64cb1c48161e9..1cf7a8d87924dd6d436c7cd17a1f7fa489d92978 100644 (file)
@@ -54,7 +54,7 @@ static bRC startRestoreFile(bpContext *ctx, const char *cmd);
 static bRC endRestoreFile(bpContext *ctx);
 static bRC createFile(bpContext *ctx, struct restore_pkt *rp);
 static bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp);
-static bRC checkFile(bpContext *ctx, char *fname);
+// Not used! static bRC checkFile(bpContext *ctx, char *fname);
 static bRC handleXACLdata(bpContext *ctx, struct xacl_pkt *xacl);
 
 /* Pointers to Bacula functions */
@@ -78,7 +78,7 @@ static pFuncs pluginFuncs = {
    pluginIO,
    createFile,
    setFileAttributes,
-   checkFile,
+   NULL,
    handleXACLdata
 };
 
@@ -152,7 +152,7 @@ DOCKER::DOCKER(bpContext *bpctx) :
       accurate_warning(false),
       local_restore(false),
       backup_finish(false),
-      unsupportedfeature(false),
+      unsupportedlevel(false),
       param_notrunc(false),
       errortar(false),
       volumewarning(false),
@@ -534,7 +534,7 @@ bRC DOCKER::handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
       /* the plugin support a FULL backup only as Docker does not support other levels */
       mode = DOCKER_BACKUP_FULL;
       if (lvl != 'F'){
-         unsupportedfeature = true;
+         unsupportedlevel = true;
       }
       break;
 
@@ -593,14 +593,27 @@ bRC DOCKER::handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
 
    /* Plugin command e.g. plugin = <plugin-name>:parameters */
    case bEventPluginCommand:
-      // Check supported level
-      if (isourplugincommand(PLUGINPREFIX, (char*)value) && unsupportedfeature){
-         DMSG0(ctx, DERROR, "Unsupported backup level. Doing FULL backup.\n");
-         JMSG0(ctx, M_ERROR, "Unsupported backup level. Doing FULL backup.\n");
-         /* single error message is enough */
-         unsupportedfeature = false;
-      }
       DMSG_EVENT_STR(event, value);
+      if (isourplugincommand(PLUGINPREFIX, (char*)value)){
+         // Check supported level
+         if (unsupportedlevel){
+            DMSG0(ctx, DERROR, "Unsupported backup level. Doing FULL backup.\n");
+            JMSG0(ctx, M_ERROR, "Unsupported backup level. Doing FULL backup.\n");
+            /* single error message is enough */
+            unsupportedlevel = false;
+         }
+
+         // check accurate mode backup
+         int accurate;
+         getBaculaVar(bVarAccurate, &accurate);
+         DMSG(ctx, DINFO, "Accurate=%d\n", accurate);
+         if (accurate > 0 && !accurate_warning){
+            DMSG0(ctx, DERROR, "Accurate mode is not supported. Please disable Accurate mode for this job.\n");
+            JMSG0(ctx, M_WARNING, "Accurate mode is not supported. Please disable Accurate mode for this job.\n");
+            /* single error message is enough */
+            accurate_warning = true;
+         }
+      }
       break;
 
    case bEventOptionPlugin:
@@ -613,7 +626,7 @@ bRC DOCKER::handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
                "... command into the Include {} block.\n");
          return bRC_Error;
       }
-      return bRC_OK;
+      break;
 
    case bEventEndFileSet:
       DMSG_EVENT_STR(event, value);
@@ -1810,6 +1823,7 @@ bRC DOCKER::setFileAttributes(bpContext *ctx, struct restore_pkt *rp)
    return bRC_OK;
 }
 
+#if 0
 /*
  * Unimplemented, always return bRC_Seen.
  */
@@ -1821,6 +1835,7 @@ bRC DOCKER::checkFile(bpContext *ctx, char *fname)
    }
    return bRC_Seen;
 }
+#endif
 
 /*
  * We will not generate any acl/xattr data, always return bRC_OK.
@@ -2008,6 +2023,7 @@ static bRC createFile(bpContext *ctx, struct restore_pkt *rp)
    return self->createFile(ctx, rp);
 }
 
+#if 0
 /*
  * checkFile used for accurate mode backup
  */
@@ -2019,6 +2035,7 @@ static bRC checkFile(bpContext *ctx, char *fname)
    DOCKER *self = pluginclass(ctx);
    return self->checkFile(ctx, fname);
 }
+#endif
 
 /*
  * Called after the file has been restored. This can be used to
index e2685cf772d1aef2a809c644a99b56ca2e839809..c151d03ac439d48f8b0f5983062541452c63da84 100644 (file)
@@ -32,8 +32,8 @@
 /* Plugin Info definitions */
 #define DOCKER_LICENSE              "Bacula AGPLv3"
 #define DOCKER_AUTHOR               "Radoslaw Korzeniewski"
-#define DOCKER_DATE                 "Oct 2019"
-#define DOCKER_VERSION              "1.2.0"
+#define DOCKER_DATE                 "Jan 2020"
+#define DOCKER_VERSION              "1.2.1"
 #define DOCKER_DESCRIPTION          "Bacula Docker Plugin"
 
 /* Plugin compile time variables */
@@ -98,7 +98,7 @@ class DOCKER: public SMARTALLOC {
    bRC pluginIO(bpContext *ctx, struct io_pkt *io);
    bRC createFile(bpContext *ctx, struct restore_pkt *rp);
    bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp);
-   bRC checkFile(bpContext *ctx, char *fname);
+// Not used!   bRC checkFile(bpContext *ctx, char *fname);
    bRC handleXACLdata(bpContext *ctx, struct xacl_pkt *xacl);
    void setworkingdir(char *workdir);
    DOCKER(bpContext *bpctx);
@@ -118,7 +118,7 @@ class DOCKER: public SMARTALLOC {
    bool accurate_warning;              /* for sending accurate mode warning once */
    bool local_restore;                 /* if where parameter is set to local path then make a local restore */
    bool backup_finish;                 /* the hack to force finish backup list */
-   bool unsupportedfeature;            /* this flag show if plugin should report unsupported feature like unsupported backup level*/
+   bool unsupportedlevel;              /* this flag show if plugin should report unsupported backup level */
    bool param_notrunc;                 /* when "notrunc" option specified, used in listing mode only */
    bool errortar;                      /* show if container tar for volume archive had errors */
    bool volumewarning;                 /* when set then a warning about remote docker volume restore was sent to user */