Restore FreePBX 15.0.16.75

CentOS 8
Kernel: 4.18.0-193.19.1.e18_2.x86_64
FreePBX v15.0.16.75
Asterisk 17.7
Backup & Restore v15.0.10.38

Trying to use the Backup & Restore to restore a FreePBX configuration with only a few modules worth of data. Getting the following error in the output

Running with: /usr/sbin/fwconsole backup --restore='/var/spool/asterisk/backup/uploads/Blank.tar.gz' --transaction='b232017b-fe27-4810-a8e8-f3c22d9d5dbf'
Determining backup file type...type is current
Starting restore job with file: /var/spool/asterisk/backup/uploads/Blank.tar.gz
Extracting Backup
Extracting backup...
Processing core
Resetting core module data
Dropping table trunks...Done
Dropping table pjsip...Done
Dropping table sip...Done
Dropping table dahdi...Done
Dropping table iax...Done
Dropping table indications_zonelist...Done
Dropping table devices...Done
Dropping table users...Done
Dropping table incoming...Done
Dropping table dahdichandids...Done
Dropping table outbound_route_patterns...Done
Dropping table outbound_route_sequence...Done
Dropping table outbound_route_trunks...Done
Dropping table outbound_routes...Done
Dropping table outbound_route_email...Done
Dropping table trunk_dialpatterns...Done
Updating tables trunks, pjsip, sip, dahdi, iax, indications_zonelist, devices, users, incoming, dahdichandids, outbound_route_patterns, outbound_route_sequence, outbound_route_trunks, outbound_routes, outbound_route_email, trunk_dialpatterns...Done
Adding emergencydevices table..Done
Migrating pickup groups to named pickup groups
Migrating call groups to named call groups
Checking for possibly invalid emergency caller id fields..none found
Migrating old media encryption values...done
Removing encoding on incoming routes alertinfo values...done
Generating CSS...Done
Restoring from core [FreePBX\modules\Core\Restore]
Processing Ampusers
Processing Astmodules
Processing Dahdichannels
Processing Devices
Processing Did
Processing Routing
Processing Trunks
Processing Users
Importing KVStore from core
Importing Feature Codes from core
Done

Processing backup
Resetting backup module data
Generating CSS...Done
Restoring from backup [FreePBX\modules\Backup\Restore]
Importing KVStore from backup
Done

Processing dashboard
The module dashboard does not seem to support restores.

Processing filestore
Resetting filestore module data
Generating CSS...Done
Restoring from filestore [FreePBX\modules\Filestore\Restore]
Importing KVStore from filestore
Done

Processing sipsettings
Resetting sipsettings module data
Dropping table sipsettings...Done
Updating tables sipsettings...Done
New SIPSettings installation detected. Initializing default settings
populating default codecs..ulaw, alaw, gsm, g726 added
Updating kvstore_Sipsettings
Migrating Audio Codecs
Generating CSS...Done
Restoring from sipsettings [FreePBX\modules\Sipsettings\Restore]
Done

Processing userman
Resetting userman module data
Remove all User Management tables
Dropping table userman_users...Done
Dropping table userman_users_settings...Done
Dropping table userman_groups...Done
Dropping table userman_groups_settings...Done
Dropping table userman_directories...Done
Updating tables userman_users, userman_users_settings, userman_groups, userman_groups_settings, userman_directories...Done
Generating CSS...Done
Restoring from userman [FreePBX\modules\Userman\Restore]
Cleaning table: userman_directories
Cleaning table: userman_groups
Cleaning table: userman_groups_settings
Cleaning table: userman_users
Cleaning table: userman_users_settings
Done

Restore processing for modules are finished successfully

In json_decode.php line 7:
                
  Syntax error  
                

backup [--backup BACKUP] [--externbackup EXTERNBACKUP] [--dumpextern DUMPEXTERN] [--transaction TRANSACTION] [--list] [--warmspare] [--implemented] [--filestore FILESTORE] [--restore RESTORE] [--restorelegacycdr] [--modules MODULES] [--restoresingle RESTORESINGLE] [--backupsingle BACKUPSINGLE] [--singlesaveto SINGLESAVETO] [--b64import B64IMPORT] [--fallback] [--useinfiledb] [--skiprestorehooks]

Attaching the Backup file as well (renamed the extension from .tar.gz tp .tgz)
Blank.tar.tgz (5.8 KB)

It seems like the restore was successful, refreshing the GUI shows the “Apply Config” button and I can see the configuration was restored as well. Why the error?

What error?

Updated the original post, for some reason the formatting messed up the message, my bad,

what about

php -v

?

php -v 7.2.24

That will likely be your problem

I yearn for the day when we can finally move beyond php v5.6. We tried to write a custom module a while back (the details of which are moot at this point) but found that we would have absolutely required v7.x to accomplish what we wanted…the libraries we needed just weren’t available/backport-able under v5.x.

@dicko, while short on the specifics, is correct…there’s still a bit of code left in v15 that is dependent on php v5.6. Granted, the biggest thing holding us back from moving to v7.x is Zend, but I digress. :zipper_mouth_face:

That said, you might be better off firing up another FreePBX system built and installed with php v5.6 from the start (Official Distro version, perhaps?) and restore all your config/data there. We’ve gone down the rabbit hole of trying to switch a system from php v7.x to v5.6 and, well, it’s an absolute nightmare. Not impossible, but you’ll be fixing dependency mismatches and endless loops of “you have to install/uninstall this before that” until your eyes glaze over and you feel like you’re about to slip into a coma. It’s not for the faint of heart, especially on a production server. :wink:

So what is the recommended PHP version? 7.4 or 5.6?

1 Like

We have no problem with 7.0 (on Debian mostly thanks to @billsimon , 7.4 starts getting flaky ) but we don’t need any commercial modules .

(You can have several versions of php on your machine, then specifically call the version you need on the fly.)

At the bottom of the output he posted.

PHP 5.6 is the version the Sangoma team tests. Anything else, you’re on your own.

Debian 10, PHP 7.3, latest FreePBX 15 works for me.

CentOS 8 makes me wrinkle up my nose… I hope that the next Distro isn’t based on it.

1 Like

So since Sangoma team tests using PHP 5.6, FreePBX 15 should have no issues whatsoever if I completely remove PHP 7.x and install 5.6?

None related to PHP compatibility.

I saw on another forum where folks were having problems with FreePBX on CentOS 8 due to Node.js version compatibility. So you may have to downgrade that component too.

I see, which version of Node.js is recommended?

Also, when you say none related to PHP, does that include all the modules (Standard and Extended only) as well?

Node v.11 works (I don’t know what is recommended)

and yes, all modules that are meant for FreePBX 15 work with PHP 5.6.

So this is what I did to debug the issue.

I edited the /var/www/html/admin/modules/backup/Json/json_decode.php and logged the $data value which the json library was trying to decode when throwing the exception. Below is the update json_decode.php (pardon my rusty PHP)

<?php
namespace FreePBX\modules\Backup\Json;

function json_decode($json, $assoc = false, $depth = 512, $options = 0) {
        $data = \json_decode($json, $assoc, $depth, $options);
        if (JSON_ERROR_NONE !== json_last_error()) {
                echo nl2br("JsonException - $data - " . $data . "\r\n");
                //throw new \JsonException(json_last_error_msg(),json_last_error());
        }
        return $data;
}

and here is the output

Processing userman
Resetting userman module data
Remove all User Management tables
Dropping table userman_users...Done
Dropping table userman_users_settings...Done
Dropping table userman_groups...Done
Dropping table userman_groups_settings...Done
Dropping table userman_directories...Done
Updating tables userman_users, userman_users_settings, userman_groups, userman_groups_settings, userman_directories...Done
Generating CSS...Done
Restoring from userman [FreePBX\modules\Userman\Restore]
Cleaning table: userman_directories
Cleaning table: userman_groups
Cleaning table: userman_groups_settings
Cleaning table: userman_users
Cleaning table: userman_users_settings
Done

Restore processing for modules are finished successfully
JsonException -  - <br />
Reloading...... DONE
Running Post Restore Hooks.. Please note that hook will restart httpd service so please refresh your page (using new ports)
post Restore hooks failed !!!!!
Running Post Restore Hooks DONE
Finished
Restore completed successfully

I’m not sure where should I look further to find out where invalid JSON was passed from.

Anything that can be looked at here? Kind of an important thing since even a fresh install backup is failing to restore on the same box that generated the backup.

In your original post it shows all the modules restored.

Now you have edited the module (not sure why) … what are you asking us to look at?

In that same post, are you seeing the error?

In json_decode.php line 7:
                
  Syntax error  

I modified the json_decode.php to get around it but doesn’t mean that it should be done that way. The question is, why is the above error thrown in the first place?

Also, when the above error is thrown, it looks like the restore process just stops and doesn’t proceed further with the rest of the stuff.

I don’t know the reason for that but it looks like the restore is already done at that point.