Backup hook - success/failure test?
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
-
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: [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.0 -
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? 0 -
At this time I don't have any way to bail on the postcpbackup script if the backup itself failed - it just runs. This would be a good feature request to submit to our team using the link in my signature. 0 -
Thanks for getting that submitted! 0
Please sign in to leave a comment.
Comments
5 comments