[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Pre- and post-action hooks
I've committed some changes to Subversion which may interest some of
you, especially those of you following bug #27. You can now configure
Cedar Backup with pre- and post-action hooks.
Hooks are configured using a couple of new configuration items in the
<options> section:
<options>
<pre_action_hook>
<action>collect</action>
<command>echo "PRE-ACTION COLLECT HOOK"</command>
</pre_action_hook>
<post_action_hook>
<action>collect</action>
<command>echo "POST-ACTION COLLECT HOOK"</command>
</post_action_hook>
</options>
Currently, hooks are limited to being shell commands. However, the code
is structured so it would be fairly easy to configure hooks that are
Python functions, maybe a little like extensions. It should also be
fairly easy to add configuration around when hooks are executed, for
instance only when the action succeeds successfully, or when the action
fails, etc.
Some users have also requested the ability to pass log messages or other
kinds of information to hooks. I don't have any specific plans for
these kinds of enhancements as of now. I'd first like to see how the
simple hooks work out, and then we can start talking about how to make
them better.
Like other shell commands within Cedar Backup, hook commands are
executed by the util.executeCommand() function rather than by a simple
call to os.system() or the like. This gives us a consistent way to log
command output and helps us avoid certain problems, but also limits the
kinds of shell commands that can be used. For instance, you can't use a
shell variable in the listed command, and you can't do file redirection
or call a subshell with `command`, etc. I don't think this is too big
of a deal, because I anticipate that most people who need a
sophisticated hook will just write a larger script and call that script
from Cedar Backup rather than listing the entire thing in configuration.
If you try this out, let the list know how you think it works, and feel
free to add more comments to the bug report if you have other ideas.
I'll probably close bug #27 when v2.7.0 is released, and open other
bug(s) for other specific enhancements as the need arises.
KEN
--
Kenneth J. Pronovici <pronovic@ieee.org>
http://www.cedar-solutions.com/
--
To unsubscribe, send mail to cedar-backup-users-unsubscribe@cedar-solutions.com.