Hi, Les Mikesell wrote on 2017-11-10 11:13:23 -0600 [Re: [BackupPC-users] Execute bash script after each share on backup server]: > On Fri, Nov 10, 2017 at 10:11 AM, Julian Zielke > <jzie...@next-level-integration.com> wrote: > > I???ve written a script which should be run after each processed share of a > > host. > > > > So I???ve tried using: > > /bin/bash /etc/BackupPC/notify.sh -c $host -s $share -t $type -r $xferOK > > > > The log says it is being executed but also: > > > > Backup failed on server01 (DumpPostUserCmd returned error status 256) > > > > When I run the script using sh -c ????????? backuppc iot runs fine. > > > > So what???s my mistake here? > > Your script needs to return an exit code of 0. [...] you can add a line > 'exit 0' at the end to make backuppc consider it successful regardless.
that was my first thought, too, but there is a bit of confusion in the question. 1. You are talking about running a script after each processed *share*, but the error message complains about DumpPostUserCmd, not DumpPostShareCmd. The remark about 'exit 0' (and all of what I'm saying) might apply to a different script, not your notify.sh, or you are doing something slightly different from what you are describing (or misquoting from memory). 2. You omit which BackupPC configuration variable you are setting to which value. It appears you might be setting $Conf{DumpPostShareCmd} = '/bin/bash /etc/BackupPC/notify.sh -c $host ...'; but then again, you might be trying the 'bash notify.sh' invocation on the command line with the variables $host, $share, $type, $xferOK quoted here instead of the actual values for clarity (or secrecy) (or because you are actually using shell variables :). In any case, I wonder why you are explicitly invoking a shell instead of using a "#!/bin/bash" line in notify.sh. With that line (and execute permission on notify.sh), things would be more consistent than what you are describing above. [There might be valid reasons like noexec mounts preventing you from doing so.] 3. You say "When I run the script using sh -c ????????? backuppc it runs fine". First observation: 'sh' is not necessarily 'bash'. Debian made a point of teaching the world that a while back. When you mean 'bash', you should say 'bash', and when you say 'sh', you should be sure you aren't using bashisms. Second observation: I don't understand the 'backuppc' in there. Did you actually mean 'su' instead of 'sh'? 4. You mention "bash notify.sh" vs. "sh -c notify.sh". Note that the semantics of ./notify.sh bash notify.sh bash -c notify.sh might be subtly different. I'd recommend selecting one version (the order says something about my preference; yours may differ), making sure it works, and then sticking to it. The point being: an "error status 256", if I'm not mistaken, might as well be a simple failure to execute the command at all. BackupPC might be telling you "I'm about to execute the following command: ..." followed by "It didn't work." - without being able to distinguish between "it failed to execute" and "it executed but returned a failure". If you want to be sure, put something like "echo `date`: here I am >> /tmp/notify.log" at the beginning of notify.sh, supposing you don't already have a different way of making sure it is really executed (I'm guessing you don't, because you say that the log tells you it is being executed, not "I'm getting the notification, so I know it is being executed"). If it's not executed, it's likely about file system permissions (of notify.sh or of /etc/BackupPC) or perhaps selinux ... If you need more help, you'd need to be more verbose on your BackupPC configuration settings and log file content. Also, file permissions as noted above and the first line of notify.sh would be interesting ... Then again, maybe it's just the missing 'exit 0'. Hope that helps. Regards, Holger ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ BackupPC-users mailing list BackupPC-users@lists.sourceforge.net List: https://lists.sourceforge.net/lists/listinfo/backuppc-users Wiki: http://backuppc.wiki.sourceforge.net Project: http://backuppc.sourceforge.net/