Post-Restore Hook not executing

Running into an issue where a post-restore hook shell script is not executing when a Warm Backup is ran.

The discussion started in this thread Exclude Trunks on Warm Spare

I’ve done a lot of troubleshooting and a lot of it is actually touched upon in this discussion Backup Restore Hooks not working

However for me the solution that @PitzKey pointed out is not working. In fact looking at the backup log I am not even seeing the job attempting to run the post-hook script.

[2023-05-16 08:11:36] [b3e6293d-c94c-4eb4-b53d-76b843108448.INFO]: Cleaning up data generated by Recording_report [] []
[2023-05-16 08:11:36] [b3e6293d-c94c-4eb4-b53d-76b843108448.DEBUG]:     Removing /tmp/recording_report_dump [] []
[2023-05-16 08:11:36] [b3e6293d-c94c-4eb4-b53d-76b843108448.INFO]: Cleaning up data generated by Sms [] []
[2023-05-16 08:11:36] [b3e6293d-c94c-4eb4-b53d-76b843108448.DEBUG]:     Removing /tmp/sms_dump [] []
[2023-05-16 08:11:36] [b3e6293d-c94c-4eb4-b53d-76b843108448.INFO]: Finished Cleaning up [] []
[2023-05-16 08:11:36] [b3e6293d-c94c-4eb4-b53d-76b843108448.INFO]: Finished created backup file: 20230516-081039-1684242639- [] []
[2023-05-16 08:11:37] [b3e6293d-c94c-4eb4-b53d-76b843108448.INFO]: Saving to selected Filestore locations [] []
[2023-05-16 08:11:40] [b3e6293d-c94c-4eb4-b53d-76b843108448.DEBUG]:     Saving to: SSH:'spare' instance ,File location: /var/spool/asterisk/backup/20230516-081039-1684242639-  [] []
[2023-05-16 08:11:40] [b3e6293d-c94c-4eb4-b53d-76b843108448.INFO]: Finished Saving to selected Filestore locations [] []

Am I just dense or is anyone else experiencing the issue?

Can you please share a bit more info?
Version? What are you trying to run? Path? etc etc etc

Yea, sorry should have done that in the original post. This is a PBXact system:

Current PBX Version:
Current System Version: 12.7.8-2302-1.sng7
backup module version: 16.0.66

Running a Warm Spare backup but basically I need to disable the trunks on the warm spare after the restore has completed (it’s a whole thing and there is an issue created for this [FREEPBX-24185] backup and Restore ( Warm spare also) Disable Trunks On Restore - Sangoma Issue Tracker).

I followed your advice from a couple of years ago and created a folder in the root of the system and gave the asterisk user permissions to it but the logs aren’t even showing that it’s trying to run the script.

Running the script manually from the CLI works just fine.

ls -al /container/
total 4
drwxr-xr-x   2 asterisk asterisk  31 May 16 08:07 .
dr-xr-xr-x. 19 root     root     284 May 16 08:07 ..
-rwxr-xr-x   1 asterisk asterisk 390 May 15 11:50

Screenshot of the relevant portion of the warm spare backup configuration:

The script:

# Date created:         05/13/2023
# Version:              1
# A script that disables asterisk trunks on the warm spare since this is not currently
# supported by the PBXact Warm Spare backup functionality.

/usr/bin/ssh -i /home/asterisk/.ssh/id_rsa [email protected]<warm spare IP> /usr/sbin/fwconsole trunks --disable 1
/usr/bin/ssh -i /home/asterisk/.ssh/id_rsa [email protected]<warm spare IP> /usr/sbin/fwconsole reload

For now I am executing the script through cron but would love to be able to get it to work through a post-restore hook.

Possible that it is running on the Warm Spare?

After looking at the backup/restore logs, I noticed that the Post-Restore script runs directly on the machine that is being restored. That is where it should be created.

So unless I’m wrong, it should be:

/usr/sbin/fwconsole trunks --disable 1
/usr/sbin/fwconsole reload

If you store the script locally on Restore Target at path /home/asterisk/ , then you should write in Post-Restore Hook “/home/asterisk/”.

I would suggest to first try with sample script to test functionality eg.

[[email protected]] # cat /home/asterisk/

echo "$(date) - This is a test" >> /home/asterisk/test.log

Make sure owner:group is asterisk:asterisk and executable by asterisk.

[[email protected]] # chown asterisk:asterisk /home/asterisk/
[[email protected]] # chmod u+x /home/asterisk/

You should notice on Restore Target’s backup log the following.

[[email protected]]# tail -10 /var/log/asterisk/backup.log
[2023-06-06 17:24:38] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.DEBUG]: Restoring custom file to /etc/asterisk/rtp_custom.conf [] []
[2023-06-06 17:24:38] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.DEBUG]: Restoring custom file to /etc/asterisk/sip_custom.conf [] []
[2023-06-06 17:24:38] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.DEBUG]: Restoring custom file to /etc/asterisk/sip_general_custom.conf [] []
[2023-06-06 17:24:38] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.DEBUG]: Restoring custom file to /etc/asterisk/sip_notify_custom.conf [] []
[2023-06-06 17:24:38] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.DEBUG]: Restoring custom file to /etc/asterisk/sip_registrations_custom.conf [] []
[2023-06-06 17:24:38] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.DEBUG]: Restoring custom file to /etc/asterisk/udptl_custom.conf [] []
[2023-06-06 17:24:38] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.INFO]: Executing Post Restore Hook: /home/asterisk/ [] []
[2023-06-06 17:25:23] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.INFO]: Running Post Restore Hooks.. Please note that hook will restart httpd service so please refresh your page (using new ports)  [] []
[2023-06-06 17:25:23] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.INFO]: Running Post Restore Hooks DONE [] []
[2023-06-06 17:25:23] [6d24fef6-9096-4b32-9a86-77c439bfa8b6.INFO]: Finished [] []

Watch the line that includes the following:
Executing Post Restore Hook: /home/asterisk/

After that you should notice on the Restore Target that the file test.log was created.

[[email protected]]# ls -l /home/asterisk/
total 8
-rw-r--r-- 1 asterisk root 47 Jun  6 17:24 test.log
-rwxr--r-- 1 asterisk asterisk 70 Jun  6 17:17

Thank you so much for doing this legwork and documenting it so well. I just couldn’t find any documentation for it that laid it out so clearly.