Hi sharmaine001,
You're correct that a Custom Event Handler is possibly your best/only solution. You can find more about the mechanics of Custom Event Handlers here:
CustomEventHandler < DevHooks < TWiki
The documentation references an example of a CustomEventHandler.pm script, /usr/local/cpanel/Cpanel/CustomEventHandler.pm.sample. You can find this on your cPanel installation.
If you look in that example, you can see how you can make the Perl "system" call which executes a system command. They use 'mkdir' in the example, but you could make a similar call to a Bash script you've made. And based on the return code of your Bash script, the CustomEventHandler can return 1 or 0 to indicate to the parent cPanel process that it should continue and do the backup/restore (or not).
One thing to note if you decide to do it this way. You should strongly consider sanitizing your variables before passing them to you Bash script, using the "system" Perl command. Anytime you pass arguments to a system or exec function, no matter what language, you should use some type of filtering so only valid data types and characters are handed to the spawned sub-shell.
Let me know if there's anything else I can help with.
Regards,
-David