Upgrade

=What Is Upgrading?= The FusionPBX code is constantly evolving - bug fixes being submitted, additions to improve security, to make it look nicer, to be more flexible, and best of all - new features. A complete summary of the changes can be found on the google code page.

=SVN Release Revisions=
 * r1 - 6 Nov 2009


 * r2523 is 3.0 release - 3 May 2012
 * r2585 is 3.0.4 release - 24 May 2012
 * r2757 is 3.1 release - 18 Aug 2012
 * r2777 is 3.1.1 release - 26 Aug 2012
 * r2827 is 3.1.2 release - 12 Sep 2012
 * r2897 is 3.1.3 release - 26 Sep 2012
 * r2907 is 3.1.4 release - 27 Sep 2012
 * r3694 is 3.2 release - 19 Jan 2013
 * r3978 is 3.3 release - 1 May 2013
 * r4605 is 3.4 release - 28 Sep 2013
 * r6747 is 3.6.1 release - 22 Aug 2014
 * r8481 is 3.8.3 release - 11 May 2014

=How to upgrade= To upgrade, you will need to get the latest source code.

Depending on how extreme the changes have been since your last update, you may need to run one-time special commands to bring your install up to date.

Potential issue with call recording after upgrading/switch to latest 3.6 stable.

After upgrading to 3.6 stable from 3.5 dev I noticed that calls were no longer being recorded. This was due to the file extension being missing from the recording path. If this is happening to you it is an easy fix.

Go to system -> variables -> category default and add the variable record_ext and set it to either wav or mp3. Choosing mp3 depends upon whether or not you have mod_shout installed and enabled.

Step 1: Update FusionPBX Source
Upgrade the code via Subversion/SVN

cd /var/www cp -R fusionpbx fusionpbx_backup cd /var/www/fusionpbx
 * Login into the web interface with a user account assigned to the superadmin group.
 * Login to the console with either the ssh, the locally.
 * Backup It's a good idea to make a backup. If using sqlite, your backup will easily include the SQL database.
 * Change the directory to the FusionPBX directory

svn update chown -Rv www-data:www-data /var/www/fusionpbx
 * Update the source code (example assumes fusionpbx is in /var/www/fusionpbx)
 * Permissions re-set the permissions on the fusionpbx directory tree - when you do svn update it sets the permissions on any updated files to match the account that you are running svn update with, therefore if that account is different to the web server account it will result in some files no longer being accessible. Therefore to fix this you should re-apply the permissions in fusionpbx and recursively in all directories inside it. The example assumes the web server runs as user 'www-data' and fusionpbx is installed to /var/www/fusionpbx. (chown -Rv Ownername:GroupName /var/www/fusionpbx)

Step 2: Update Freeswitch Scripts
NOTE: As of FusionPBX 3.8.3 (Stable Branch), the scripts should be automatically updated when updating the Source Code, using the Advanced > Upgrade page. Any customized scripts, having the same name as the default scripts, will be overwritten. (An option to disable this default behavior is available using a Default Setting: switch > scripts_update > false) Missing scripts will be restored, and any additional files within the scripts folder will remain untouched.

FusionPBX is a fast moving project where features are constantly being added and bugs are being fixed on a daily basis so I would also suggest upgrading the Freeswitch scripts directory as part of any normal upgrade process.

Subversion Use subversion to get the updated files. You have to do this from an empty directory. cp -R /usr/local/freeswitch/scripts /usr/local/freeswitch/scripts-bak rm -Rf /usr/local/freeswitch/scripts/ cd /usr/local/freeswitch svn checkout http://fusionpbx.googlecode.com/svn/branches/dev/fusionpbx/resources/install/scripts/ chown -R www-data:www-data /usr/local/freeswitch/scripts cp /usr/local/freeswitch/scripts-bak/resources/config.lua /usr/local/freeswitch/scripts/resources/config.lua (The last step above is not required if your config.lua file is being stored in a different location, such as the /etc/fusionpbx folder.)

An alternative is to remove the Lua scripts. Only do this if you haven't customized any LUA scripts cp -R /usr/local/freeswitch/scripts /usr/local/freeswitch/scripts-bak rm -rf /usr/local/freeswitch/scripts/*
 * Clean out this scripts directory

Here you need to go directly to section 3 and make sure you run upgrade schema from the GUI immediately otherwise your calls will not complete.
 * Pull the most recent scripts down

If your config.lua file was located in scripts/resources/, then you'll need to restore it (from the backup previously performed) to scripts/resources/config.lua.
 * Restore the config.lua file (IMPORTANT!!)

Step 3: Upgrade Schema
Many updates have changes to the database and to the Freeswitch scripts. The upgrade_schema script


 * Upgrade from the GUI
 * From within the web site, run Advanced -> Upgrade Schema which will add any needed newer tables or columns.
 * Then run App Defaults. If you removed the scripts on Step 2 then run this twice.


 * Upgrade from the Command Line An alternative to running upgrade_schema.php from the GUI is to run the upgrade.php from the command line. It was designed to make the upgrade easier. If you did not login when updating the FusionPBX source code then you will need to run the upgrade.php file from the command line. Make sure to use the full path to the PHP file.

cd /var/www/fusionpbx /usr/bin/php /var/www/fusionpbx/core/upgrade/upgrade.php
 * 1) as root run the following

http://domain_or_ip/mod/users/usersupdate.php Then scroll down to where it says "Template" and select one of the valid templates from the drop down list. Then press Save. It will be fixed now and you can continue with the remaining steps below. (Note that any users who have invalid templates selected will also have the same problem you did - but you can fix them from the user manager option in the accounts menu)
 * If your screen was nicely formatted with a fusionpbx theme, and suddenly now goes to a black and white screen with familiar text but no theme, it is because you were using a theme which no longer exists in the latest version of the code. If this happens to you navigate to:

Step 4: Apply permissions and Restart Freeswitch
chown -Rv www-data:www-data /usr/local/freeswitch/
 * Make sure that the freeswitch directory has the correct permissions

service freeswitch restart
 * Restart Freeswitch

Step 5: Menu
especially needed if your menu disappeared.

v1 and v2
Now update the menu to the latest version.

http://domain_or_ip/core/menu/menu_restore_default.php

Press 'Restore Default' on the top right.

v3

 * 1) https://your.ip/core/menu/menu.php
 * 2) click 'e' next to the default menu
 * 3) click the restore default button.
 * 4) https://your.ip/logout.php
 * 5) https://your.ip/login.php

Step 6: Re-generate Settings
Sometimes variable names changes. In rev 1877 v_config_cli.php variable names changed which caused no fax to email emails or voicemail emails to be sent as the SMTP details did not exist.

Go to System -> Settings and then click save. This will re-generate v_config_cli.php and any other needs config files.

Upgrade Path
Version specific instructions.

Version 3.6 to 3.8
Note: If the production system is critical or you are intimidated about these upgrade instructions you might FusionPBX paid support at http://www.fusionpbx.com/support.php

A standard 'upgrade' procedure should always be followed (1. Make a Backup!, 2. Advanced > Upgrade steps, 3. Update switch scripts, 4. Restart FreeSWITCH).

Beyond the standard upgrade procedure just described, the following will also need to be performed:

If you go to Advanced Group Manager -> And you see what looks like duplicates of user, admin and superadmin groups then you need do the following instructions.
 * Rebuild all time conditions.
 * After you edit a particular time condition, click the Dialplan button on the top right to see what was there originally.
 * Delete the following dialplans from each domain then run Advanced -> Upgrade -> App Defaults. If using XML handler for the dialplan flush memcache. If using dialplans XML on the file system resave one of the dialplans to have FusionPBX rewrite the XML files.
 * user_exists - call_timeout variable was added
 * extension-intercom - It has been renamed to 'page-extension'
 * eavesdrop - Change *88[ext] to *33[ext] so that it doesn't conflict with page-extension at *8[ext]
 * user_status - Has been renamed to 'agent_status'
 * page - Dialplan has been simplified.
 * valet_park_out - Changed regex variable from $1 to $2
 * local_extension - failure handler was added to support call forward on busy and no answer
 * If using call center feature code *22 edit each agent and add an agent id and password (pin number)
 * Delete any dialplan with the 'features' context. These have been moved into the dialplan domain contexts.
 * If using App -> XMPP, Content Manager, or Schema they have been moved dev -> branches -> apps directory need to pull files from there if you want to use any of them.
 * For single tenant systems 'default' context is no longer used by default.
 * Easiest way to update your system is go to Advanced -> Domains and edit your domain.
 * Copy your current domain name then change the name to default then save the change.
 * Now edit the domain name again and paste your original domain name or IP address whatever the domain originally was and save the changes
 * Go to accounts extensions and save one extension. (not needed if using the XML handler)
 * Go to Dialplan Manager and save one of the dialplans. (not needed if using the XML handler)
 * FAX ( may require adjusting the paths and web server user account to match your server 'www-data' is used in this example)
 * Delete all previous FAX dialplans
 * Resave each fax server in the GUI.
 * cd /var/www/fusionpbx/app/fax
 * wget https://fusionpbx.googlecode.com/svn/branches/dev/scripts/upgrade/fax_import.php
 * chown -R www-data:www-data fax_import.php
 * Login into the GUI and use this path in your browser http:///app/fax/fax_import.php
 * rm /var/www/fusionpbx/app/fax/fax_import.php
 * Groups and Permissions

Remove permissions associated with all domain groups with names that match default global groups... Use the Advanced -> SQL Query tool to do the following.

delete from v_group_permissions where domain_uuid is not null and (       group_name = 'user'        or group_name = 'admin'        or group_name = 'superadmin'        or group_name = 'agent'        or group_name = 'public'    )

Remove all domain groups having the same names as the default global groups (retains any custom domain groups)...

delete from v_groups where domain_uuid is not null and (       group_name = 'user'        or group_name = 'admin'        or group_name = 'superadmin'        or group_name = 'agent'        or group_name = 'public'    )

Empty the group_uuid field for any group user with a group_name value having the same name as the default global groups (retains user assignments to custom domain groups)...

update v_group_users set group_uuid = null where group_name = 'user' or group_name = 'admin' or group_name = 'superadmin' or group_name = 'agent' or group_name = 'public'

For group users with a null group_uuid, insert the group_uuid of the global group that matches the group_name value... Run this code from Advanced -> Command -> PHP Command.

$sql = "select group_user_uuid, group_name "; $sql .= "from v_group_users where group_uuid is null"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute; $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset($prep_statement); if ($result_count > 0) { foreach($result as $field) { //note group user uuid $group_user_uuid = $field['group_user_uuid']; $group_name = $field['group_name']; //get global group uuid $sql = "select group_uuid from v_groups "; $sql .= "where domain_uuid is null "; $sql .= "and group_name = '".$group_name."' "; $prep_statement = $db->prepare($sql); $prep_statement->execute; $sub_result = $prep_statement->fetch(PDO::FETCH_ASSOC); $sub_result_count = count($sub_result); unset ($prep_statement); //set group uuid if ($sub_result_count > 0) { $sql = "update v_group_users "; $sql .= "set group_uuid = '".$sub_result['group_uuid']."' "; $sql .= "where group_user_uuid = '".$group_user_uuid."' "; $count = $db->exec(check_sql($sql)); unset($sql); }       }    }

Apps menu disappeared

If your apps menu disappeared check that it wasn't set to protected in the menu manager (advanced -> menu manager). If protected is true, it won't show up.

Version 3.5 to 3.6
When running Upgrade -> Schema If you see ALTER TABLE v_xml_cdr ADD json json; every time you run the upgrade schema then you likely have an old version of Postgres to fix this either upgrade to the latest Postgres server or run the following SQL statement from advanced -> sql query.

ALTER TABLE v_xml_cdr ADD json text;

See https://code.google.com/p/fusionpbx/issues/detail?id=655&can=1&q=json for more details.

Version 3.4 to 3.5
Gateways now use the gateway_uuid as the name that is used when interacting with FreeSWITCH. This script is needed to help change the gateway names used in the outbound routes. You may need to remove the old gateway file names from the conf/sip_profiles/external directory.

cd /var/www/fusionpbx wget http://fusionpbx.googlecode.com/svn/branches/dev/scripts/upgrade/gateway_uuid.php http://x.x.x.x/gateway_uuid.php rm gateway_uuid.php Switch Category -> Sub category gateways change to sip_profiles
 * Go To Advanced -> Default Settings

Permissions Issues - (access denied errors) Due to changes which improve consistency throughout the product, some Users have had problem with superadmin receiving "access denied" errors after the upgrade.


 * Go To Advanced -> Group Manager
 * On 'superadmin" click Permissions and then Restore Default

You may need to execute this operation for each group.

Default Settings In the switch category change gateways to sip_profiles

Version 3.3 to 3.4
Update the source as described on this page, menu manager 'restore default', group manager edit a group 'restore default', advanced -> upgrade schema.

FusionPBX 3.4 hunt groups have been deprecated. Use the following script run it only one time to move existing hunt groups to ring groups. cd /var/www/fusionpbx wget http://fusionpbx.googlecode.com/svn/branches/dev/scripts/upgrade/hunt_group_export.php http://x.x.x.x/hunt_group_export.php rm -r hunt_group_export.php

Ring groups were expanded to add ability to call external numbers and match other missing hunt group features. A new table was created to accomodate this. cd /var/www/fusionpbx wget http://fusionpbx.googlecode.com/svn/branches/dev/scripts/upgrade/ring_group_extensions.php http://x.x.x.x/ring_group_extensions.php rm ring_group_extensions.php

Version 3.2 to 3.3
FreeSWITCH changed the syntax to connect to the database so numerous LUA scripts had to be updated. If you customized any of the lua scripts make a backup of the FreeSWITCH scripts directory. Then remove the contents of the freeswitch/scripts directory and then run advanced -> upgrade schema (which will detect the missing scripts and replace them).

Version 3.1.4 to 3.2
Ubuntu/Debian cd /var/www/fusionpbx svn update Advanced -> Upgrade Schema

Menu
If you cant see the menu after upgrading try the following in your browser replace x.x.x.x with your ip or domain name. x.x.x.x/core/menu/menu.php Edit the menu make sure the language is set to en-us. Press 'Restore Default'

Default settings
x.x.x.x/core/default_settings/default_settings.php category: language type: code value: en-us

Email
Migrating email to the new FusionPBX native voicemail. wget http://fusionpbx.googlecode.com/svn/trunk/scripts/upgrade/voicemail_export.php

Run from the browser it will take the voicemail data from the FreeSWITCH database and copy the information into the FusionPBX database. http://x.x.x.x/voicemail_export.php

Remove the export file rm voicemail_export.php

Call Forward / Follow Me
No longer using hunt groups. So the backend has changed so keep in mind that you need to reset call forward and follow me settings. They are still listed in app -> hunt groups. After updating the info in call forward, follow me you should delete the hunt group.

Version 2 to 3.0
http://code.google.com/p/fusionpbx/source/browse/#svn%2Ftrunk%2Fscripts%2Fupgrade
 * LESS than or EQUAL to revision 1877, use the migration tool.

svn update
 * If greater than revision 1877, use latest.

See 3.0 Upgrade Notes.

Additional Info
Revision

How to get the FusionPBX revision number: Ubuntu/Debian svn info /var/www/fusionpbx

Version

How to get the FusionPBX version number. Menu -> Status -> System Status

Notes

If your version is from... update v_groups set groupid = 'user', groupdesc = 'User Group' where groupid = 'member'; update v_group_members set groupid = 'user' where groupid = 'member';
 * before 2011-01-04 - r669 - then you'll need to run the following commands from the Advanced -> SQL Query tool. These changes the group member to user. It also moves all users who are members of the 'member' group over to the 'user' group.
 * Click Execute (Type 'default', Table 'leave blank' Click Execute)
 * results: 0 for both queries
 * Log out
 * Log in
 * Proceed to update the menu

"Apply settings automatically with an option to display the apply settings prompt with a variable in system -> variables -> apply_settings = true"
 * before 2011-02-20 r836

If things go wrong: SQLite Database Restore
You shouldn't need to do this, and it's probably the wrong thing to do, but if your database won't load after an upgrade...

Synopsis of what happened [to me]
You're probably seeing an error like this: (Fatal error: Call to a member function execute on a non-object in /var/www/fusionpbx/includes/menu.php on line 76)
 * 1) You were not logged into the browser interface
 * 2) You updated from svn via CLI
 * 3) You went to login to run upgrade->Schema, but couldn't due to some changes.

Remedy
mv /var/www/fusionpbx /var/www/fusionpbx.bak reinstall the lastest fusionpbx...
 * from cli:
 * if you are using svn checkout make sure you set the permissions correctly on the fusionpbx directory structure before proceeding to the next step

login via the gui, complete the install... Don't log out cd /var/www/fusionpbx/secure mv fusionpbx.db fusionpbx.db.new cp /var/www/fusionpbx.bak/secure/fusionpbx.db ./ chown www-data:www-data fusionpbx.db   (or whatever your webserver user/grp is) go to: http://domain_or_ip/core/upgrade/upgrade_schema.php This should fix the database. You will need to have FusionPBX recreate all of the FreeSWITCH xml files. When you reinstalled, they were properly deleted (the database was empty at that point). Edit an extension/gateway/route/etc, and click save (you won't need to edit it).
 * from browser
 * back to cli
 * from browser

In the future
Make sure you're logged into the browser interface before doing an upgrade...