Call for contributors: Include Dynamic Routes in Backup/Restore

Hello,

In FreePBX 15, Dynamic Routes are not included in Backup/Restore. I assume that this is due to the way Backup/Restore was re-written in FreePBX 15+ which requires additional functions added to the actual module code.

I am no PHP developer, but if someone can tell me which module might have similar Backup/Restore code that would work for DynRoutes, then I can try to draft something.

Thanks

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.

@john2 is working on this now, as well as a few other minor issues. I will post a link once it’s public.

1 Like

Here’s the PR, need to be signed in to see it. Please test if you’re in a position to do so

Seems like this is for FreePBX16 only? (Version 16.1.0)

Tested this on FreePBX 15. Backup and restore seems to be working fine.

Here are the steps that I did.

  1. Deleted the current version of DynRoutes
  2. Installed this version.
  3. Created a DynRoute object.
  4. Applied config
  5. Created a backup to only backup the DynRoutes module
  6. Ran the backup
  7. Deleted the DynRoute object
  8. Applied config.
  9. Restored the backup via command line.
  10. Confirmed that DynRoute object was restored.

The below is a bit unrelated to this topic…
I noticed that DynRoutes depends on Core, Recordings & Soundlang.

Doesn’t the including dependencies idea sort of defeat the feature of allowing us to restore a specific module only to a certain state?
I guess there are two things that need to happen.

  1. Show in the GUI what modules will be included in this backup. I know it says in the log. But the logs are sometimes very long and you can easily miss the line where it says so.
  2. Either during backup or restore allow the admin to exclude the dependencies with a big banner “AT YOUR OWN RISK”

Anyway, back to getting this version released. Is there anything else that needs testing?

I would like to test this. Can you give more details for step 1 and 2, delete and install?

Thinking now that I could’ve probably skipped step 1 and go straight to step 2, but I didn’t try…

  1. fwconsole ma delete dynroute (or whatever the module name is) and reload fwconsole reload. Note: this will actually delete all the Dynamic Routes data you currently have. So perhaps try going straight to step 2 which shouldn’t delete anything.
  2. Download that ZIP file, go to module admin, upload this zip from your hard disk, once uploaded go back to the module list and click install.

Let me know if you have any trouble

For future note as this doesn’t seem to be documented anywhere. I put it in there to speed development…

fwconsole backup --backupsingle [modulename] --singlesaveto /some/path/foo.tgz
fwconsole backup --restoresingle /some/path/foo.tgz

You can use the above to backup/restore individual modules. No need to make a backup job or do anything fancy

2 Likes

Cool. Thanks!

Does it include the dependencies tho?

80% sure (without looking at the code) it calls only the modules methods and does not do dependencies

1 Like

It indeed says that it doesn’t process dependencies in restore mode. However, it seems to be a bit buggy.

[root@freepbx ~]# fwconsole backup --backupsingle ivr --singlesaveto /var/spool/asterisk/backup
Transaction ID is: e4c718a9-7254-4692-9644-a14b3719ca19
Processing ivr
Working with ivr module
        Adding module manifest for ivr
***In single restores mode dependencies are NOT processed***
There was nothing to cleanup
Finished created backup file: /var/spool/asterisk/backup/ivr-20220609-132138-1654795298-15.0.29-1337915437.tar.gz
PHP Fatal error:  Call to undefined method FreePBX\modules\Backup\Handlers\Backup\Single::sendEmail() in /var/www/html/admin/modules/backup/Console/Backup.class.php on line 126
PHP Stack trace:
PHP   1. {main}() /var/lib/asterisk/bin/fwconsole:0
PHP   2. Symfony\Component\Console\Application->run() /var/lib/asterisk/bin/fwconsole:163
PHP   3. Symfony\Component\Console\Application->doRun() /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:148
PHP   4. Symfony\Component\Console\Application->doRunCommand() /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:255
PHP   5. Symfony\Component\Console\Command\Command->run() /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:960
PHP   6. FreePBX\Console\Command\Backup->execute() /var/www/html/admin/libraries/Composer/vendor/symfony/console/Command/Command.php:255
Whoops\Exception\ErrorException: Call to undefined method FreePBX\modules\Backup\Handlers\Backup\Single::sendEmail() in file /var/www/html/admin/modules/backup/Console/Backup.class.php on line 126
Stack trace:
  1. Whoops\Exception\ErrorException->() /var/www/html/admin/modules/backup/Console/Backup.class.php:126
  2. FreePBX\Console\Command\Backup->execute() /var/www/html/admin/libraries/Composer/vendor/symfony/console/Command/Command.php:255
  3. Symfony\Component\Console\Command\Command->run() /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:960
  4. Symfony\Component\Console\Application->doRunCommand() /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:255
  5. Symfony\Component\Console\Application->doRun() /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:148
  6. Symfony\Component\Console\Application->run() /var/lib/asterisk/bin/fwconsole:163
  7. {main}() /var/lib/asterisk/bin/fwconsole:0

Someone added something without testing :dotted_line_face: but hey this was generally just a tool for me when I had to write and test backup in every single module. I know it is in internal documentation but nobody reads that so it is unlikely anyone except me even knows about this.

Not that you know what is or isn’t written by me but most things i have done heavy work on typically have console commands that can be useful for testing and troubleshooting :slight_smile:

1 Like

dynroute v15.0.3
dynroute v16.0.2

Thank you @kgupta @lgaetz

1 Like

This is also fixed in the latest backup edge version. Thank you @kgupta

Running backup (note, you can only save to /var/spool/asterisk/backup)

[root@freepbx ~]# fwconsole backup --backupsingle ivr --singlesaveto /var/spool/asterisk/backup
Transaction ID is: d2c3c894-4c68-49eb-827f-cbc1d899967d
Processing ivr
Working with ivr module
        Adding module manifest for ivr
***In single restores mode dependencies are NOT processed***
There was nothing to cleanup
Finished created backup file: /var/spool/asterisk/backup/ivr-20220615-065909-1655290749-15.0.29-180725149.tar.gz
Backup completed successfully

Restoring the backup:

[root@freepbx ~]# fwconsole backup --restoresingle /var/spool/asterisk/backup/ivr-20220615-065909-1655290749-15.0.29-180725149.tar.gz
Transaction ID is: c22156c1-1da1-40f7-b49a-7d3a0bccd2f2
Extracting backup...
***In single restores mode dependencies are NOT processed***
Resetting ivr module data
Dropping table ivr_entries...Done
Dropping table ivr_details...Done
Updating tables ivr_entries, ivr_details...Done
Generating CSS...Done
Restoring from ivr [FreePBX\modules\Ivr\Restore]
Done
Finished
Restore completed successfully

Whoever has permissions, please update the wiki. Thank you

Sangoma Documentation

1 Like

Thank you, Lorne!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.