The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'cPanel Developers' started by sharmaine001, May 1, 2010.

Thread Status:
Not open for further replies.
  1. sharmaine001

    sharmaine001 Well-Known Member

    Joined:
    Jun 23, 2006
    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    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
     
  2. sharmaine001

    sharmaine001 Well-Known Member

    Joined:
    Jun 23, 2006
    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    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?
     
  3. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    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
     
  4. sharmaine001

    sharmaine001 Well-Known Member

    Joined:
    Jun 23, 2006
    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    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
     
    #4 sharmaine001, May 2, 2010
    Last edited: May 2, 2010
  5. sharmaine001

    sharmaine001 Well-Known Member

    Joined:
    Jun 23, 2006
    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    Sorry to bug you but no help?
     
  6. sharmaine001

    sharmaine001 Well-Known Member

    Joined:
    Jun 23, 2006
    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    no help from cpanel developers?
     
  7. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    We don't perform work-for-hire. There are plenty of outside resources you can turn to for custom development.
     
Loading...
Thread Status:
Not open for further replies.

Share This Page