Backup hook - success/failure test?

laxbobber

Member
Jan 4, 2005
10
0
151
cPanel Access Level
Root Administrator
Greetings all -

I am working on a way to query the servers remotely so I can know when a backup has completed. This way I can rsync my /backup/ folder by pulling instead of pushing it from the server. The goal is to make the backup server inaccessible from the cPanel server.

Which leads me to my question... in the /scripts/postcpbackup script, how can I know if the backup was successful or if it failed? I would like to script it such that the "OK to download" indicator isn't there if something went wrong and the cpbackup ended in failure. Is there a command I can run to know the last cpbackup ending status? Or is there a way to know inside the /scripts/postcpbackup script if the backup was successful?

Thanks!
Bob
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,027
313
cPanel Access Level
Root Administrator
Hey there! In general, the postcpbackup file would only contain custom content as that isn't something that is created by cPanel by default. You'd need to further modify the existing script file to perform those additional functions, but I'm afraid I wouldn't have exact details on how to go about that.

I know our standard backup notification does notify the server administrator email if the backup was successful, with something similar to this:

Code:
[2021-09-01 02:17:36 -0400] info [backup] leaving queue_backup_transport_item
[2021-09-01 02:17:36 -0400] info [backup] Completed at Wed Sep 1 02:17:36 2021
[2021-09-01 02:17:36 -0400] info [backup] Final state is Backup::Success (0)
but that code wouldn't be able to be applied to a custom script.
 

laxbobber

Member
Jan 4, 2005
10
0
151
cPanel Access Level
Root Administrator
Thanks @cPRex! Are you saying that cPanel will call postcpbackup but there's no way to know if the backup was successful other than determining which is the most recent log file and parsing it to look for "Final state is Backup::Success"?

Maybe my question is best re-asked as: Is there a way to make cPanel NOT call postcpbackup if the backup has failed?