From: Radosław Korzeniewski Date: Wed, 15 Jan 2020 08:47:48 +0000 (+0100) Subject: Fix Docker Plugin for accurate backup. X-Git-Tag: Release-9.6.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f43fbe1a5505975e7bf3c4753423df319c078f41;p=thirdparty%2Fbacula.git Fix Docker Plugin for accurate backup. --- diff --git a/bacula/.gitignore b/bacula/.gitignore index ffa46b4e9..6a3a632a3 100644 --- a/bacula/.gitignore +++ b/bacula/.gitignore @@ -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 diff --git a/bacula/src/plugins/fd/docker/docker-fd.c b/bacula/src/plugins/fd/docker/docker-fd.c index 7082001d4..1cf7a8d87 100644 --- a/bacula/src/plugins/fd/docker/docker-fd.c +++ b/bacula/src/plugins/fd/docker/docker-fd.c @@ -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 = :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 diff --git a/bacula/src/plugins/fd/docker/docker-fd.h b/bacula/src/plugins/fd/docker/docker-fd.h index e2685cf77..c151d03ac 100644 --- a/bacula/src/plugins/fd/docker/docker-fd.h +++ b/bacula/src/plugins/fd/docker/docker-fd.h @@ -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 */