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.

rsync after backup ends

Discussion in 'Data Protection' started by adjc98, Jul 29, 2015.

  1. adjc98

    adjc98 Registered

    Joined:
    Jul 16, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Charlotte, NC
    cPanel Access Level:
    Root Administrator
    Hello,

    I am trying to do an rsync after the cpanel backup ends. I am using the new backup system for cpanel and not the legacy. I am having trouble finding documentation on the new backup system.

    In the legacy backups you would add POSTBACKUP 1 TO /etc/cpbackup.conf file
    and add the rsync command to the file /scripts/postcpbackup to run the command after cpanel backup got finished.

    In the new system the backup conf file is in /var/cpanel/backups/config

    I changed POSTBACKUP: 'no' to POSTBACKUP: 'yes' .

    What is not clear to me is if we should call /scripts/postbackup instead of /scripts/postcpbackup for the new post backup file to be called after cpanel is done.

    I read this on another post, but don't know where to start:

    The new backup system uses the standard hook system we introduced in 11.32. Through that, bin/backup exposes both a pre and a post hook event.

    I am not seeing the documentation for bin/backup and pre/post can someone point me in the right direction please?
     
  2. ModServ

    ModServ Well-Known Member

    Joined:
    Oct 17, 2006
    Messages:
    332
    Likes Received:
    5
    Trophy Points:
    18
    Location:
    Egypt
    cPanel Access Level:
    Root Administrator
    From backup script "/usr/local/cpanel/bin/backup", you can find this:
    /usr/local/cpanel/scripts/postcpbackup

    Code:
        if ( -e '/usr/local/cpanel/scripts/postcpbackup' && -x _ && ( !exists $$conf_ref{'POSTBACKUP'} || $$conf_ref{'POSTBACKUP'} ) ) {
            $logger->info("Executing user defined post backup script (/usr/local/cpanel/scripts/postcpbackup).");
            system '/usr/local/cpanel/scripts/postcpbackup';
        }
    
     
  3. adjc98

    adjc98 Registered

    Joined:
    Jul 16, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Charlotte, NC
    cPanel Access Level:
    Root Administrator
    I am assuming the script above is in pearl. I am not familiar with pearl, but what it looks like is that postcpbackup should be ran after the cpanel backup process is over.

    What I have in /usr/local/cpanel/scripts/postcpbackup doesn't get run after I do a backup. Is there something else I should do to make the if statement run true? I am not sure what -x _ is for and I have both config files for set for true for legacy and new backup.

    if ( -e '/usr/local/cpanel/scripts/postcpbackup' && -x _ && ( !exists $$conf_ref{'POSTBACKUP'} || $$conf_ref{'POSTBACKUP'} ) ) {
    $logger->info("Executing user defined post backup script (/usr/local/cpanel/scripts/postcpbackup).");
    system '/usr/local/cpanel/scripts/postcpbackup';
    }

    Is there something I need to restart so the config files are updated in the config cache?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    653
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    You can register a hook after creating the custom script you want to run after backup generations with a command such as:

    Code:
    /usr/local/cpanel/bin/manage_hooks add script /root/post_backup --category System --event Backup --stage post
    This assumes your script is located at /root/post_backup.

    Thank you.
     
Loading...

Share This Page