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.

Confirming backups have completed

Discussion in 'Data Protection' started by nathanics, Feb 12, 2015.

  1. nathanics

    nathanics Registered

    Joined:
    Feb 12, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    a good while back I had written a script that worked with the legacy backup system to automatically rotate backup folders. In that script I was used `find /usr/local/cpanel/logs/cpbackup/ -mmin -600` to confirm a log file was created for today's backup. Then it checked the last 2 lines of that log file for "Completed" to confirm the backup had finished. This worked because logs for successful backups ended with a string like "[cpbackup] Completed at Tue Oct 21 01:25:45 2014"

    I've been using the new backup system for a while now in place of my script, but have come across the need to write another script for a different purpose. Again I need to be able to tell if the backup has completed successfully, and I just noticed the New Backup system does not appear to finish the logs with the same completed message. I've been looking through backup logs over the past year and they all just stop after the last account that was backed up.

    Is there a way with the new backup system that I can confirm a backup has run and completed successfully?

    Thanks,
    Nathan
     
  2. arjanvr

    arjanvr Well-Known Member

    Joined:
    Dec 13, 2013
    Messages:
    58
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    It is sending an email when done. Or at least with me
     
  3. nathanics

    nathanics Registered

    Joined:
    Feb 12, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    It does send me an email, but I need a bash script to confirm the backup has finished before it moves on.
     
  4. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,146
    Likes Received:
    34
    Trophy Points:
    48
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    I think there is simple way to run your won backup scripts after the cPanel backup scripts. For this you will have to create /scripts/postcpbackup scripts and enable this backup hook through WHM »Development »Manage Hooks so that your /scripts/postcpbackup script will be run automatically when your cpanel backup is completed.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

    You could use an event hook to run a script at the completion of the backup process:

    Guide to Standardized Hooks

    You can register a hook after creating the script with a command such as:

    Code:
    /usr/local/cpanel/bin/manage_hooks add script /root/post_backup --category System --event Backup --stage post
    Thank you.
     
  6. nathanics

    nathanics Registered

    Joined:
    Feb 12, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    In my case the script i'm creating will actually be ran from a remote server so it cannot be called directly by the post backup hook. But with that information i can write the post_backup script to touch a file and monitor that file from my remote script and i think that will get me where I need to be. Just one follow up question, is there any condition where we fail to create a successful backup but the post backup script still gets triggered?

    Thanks for all the info/help
    -Nathan
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    The hook should happen after the backup process completes, regardless of if an account backup fails to generate. It's rare that a backup generation fails, so it's something that should be addressed to determine why it happens.

    Thank you.
     
Loading...

Share This Page