Hi,

our bacula setup relies on the bpipe plugin more or less heavily. We use said 
plugin for a number of scenarios including database and ldap backup, imap 
mailbox list backup, and others.

At this time, the return code of the restore is lost. This results in a 
successful job state ("OK") even when problems during restore occured. While 
we can control the exit code of the bpipe restore command, we don't have a 
chance to make the error visible in any way. Unfortunately, the output of the 
restore command is lost as well, but I don't see any simple chance to modify 
that.

The attached patch makes the job terminate in an error state in two locations:

a) The bpipe plugin checks the exit value of the restore process. With the 
patch applied, a JobMessage with type M_ERROR is issued, giving the file name 
of the failing file, and the return code of the pclose() call.

b) When any (!) plugin closes during restore, and returns an io.status (i.e., 
the exact same value checked in bpipe in (a)) != 0, an M_ERROR message is 
issued, giving the plugin name, and the return code.

Please note that (b) may trigger error messages for plugins other than bpipe. 
One might argue that it requires additional design for the question whether an 
io.status != 0 is to be regarded an error for all plugins, or whether that is 
a bpipe only behavior. I have not checked any included plugin (and obviously 
have not checked any third-party or commercial plugins).

It may be sensible to only apply the bpipe chunk of the patch, if all other 
existing plugins already do their error handling during closing their streams.

Please feel free to use this patch in upstream or any other bacula editions. 
You have my signed FLA.

Thx
   Bastian

-- 
Collax GmbH . Basler Str. 115a . 79115 Freiburg . Germany
p: +49 (0) 89-990 157-28        www.collax.com

Geschäftsführer: Bernd Bönte, Boris Nalbach
AG München HRB 173695. Ust.-IdNr: DE270819312
--- bacula-5.2.6.ori/src/findlib/bfile.c	2012-02-21 16:59:33.000000000 +0100
+++ bacula-5.2.6/src/findlib/bfile.c	2012-03-29 12:44:54.000000000 +0200
@@ -1029,6 +1029,9 @@
 
    if (bfd->cmd_plugin && plugin_bclose) {
       stat = plugin_bclose(bfd);
+      if (stat) {
+         Jmsg2(bfd->jcr, M_ERROR, 0, _("Error closing stream for plugin %s: %d\n"), bfd->jcr->plugin->file, stat);
+      }
       bfd->fid = -1;
       bfd->cmd_plugin = false;
    }
--- bacula-5.2.6.ori/src/plugins/fd/bpipe-fd.c	2012-02-21 16:59:33.000000000 +0100
+++ bacula-5.2.6/src/plugins/fd/bpipe-fd.c	2012-03-29 12:08:31.000000000 +0200
@@ -414,6 +414,9 @@
          return bRC_Error;
       }
       io->status = pclose(p_ctx->fd);
+      if (io->status) {
+         bfuncs->JobMessage(ctx, fi, li, M_ERROR, 0, "bpipe plugin: Error closing stream for pseudo file %s: %d\n", p_ctx->fname, io->status);
+      }
       break;
 
    case IO_SEEK:
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to