way to insert a hook in cpanel's backup manager?

Status
Not open for further replies.

sharmaine001

Well-Known Member
Jun 23, 2006
143
0
166
I want to execute a bash script before a user generates cpanel full backup file or before a user uploads a home directory backup or sql backup, is that possible? I searched for hooks but only find one for cpbackup.

I hope cPanel can help me. This is very important

I dont want to edit cpanel's script because they will be overwritten after cpanel update
 

sharmaine001

Well-Known Member
Jun 23, 2006
143
0
166
I read a related problem here: http://forums.cpanel.net/f42/pre-hooks-similar-cpanel-backups-120521.html

The poster was advised to use custom event handler. Unfortunately I do not know perl and I cannot write a perl script. And I don't know what event is called for backup manager's functions.

Can someone help me with the custom event handler code?

What i want is pre cpanel full backup generation, pre home directory upload and pre mysql directory upload

I can only write simple linux bash scripts, so I want the pre cpanel even check to execute a bash script

Basically I want to disallow cpanel full backup generation if the total files > 50,000 or total files to backup is > 4 GB.

I also want to disallow home directory upload > 4 GB and mysql upload > 1 GB

Can someone help me? cPanel developers?
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
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
 

sharmaine001

Well-Known Member
Jun 23, 2006
143
0
166
I did check the samples before I post them here but I really couldn't understand how I can make a call to the bash script in perl and pass variables. I also dont know the API function to call

Can you please help me develop the event?

What i want is pre cpanel full backup generation, pre home directory upload and pre mysql directory upload

Basically I want to disallow cpanel full backup generation if the total files > 50,000 or total files to backup is > 4 GB.

I also want to disallow home directory upload > 4 GB and mysql upload > 1 GB
 
Last edited:
Status
Not open for further replies.