Backup and Restore Version 15+
Introduction
In FreePBX 15+ our backup module was redesigned for simplicity, flexibility and maintainability. Storage options are now handled in the Filestore module which offers more options to keep your data safe. You can now backup per module. This allows you to create custom backups of just the data you need. You can also divide your modules in to different backups for data that may change more often. With each module handling the data it owns we can now do cross-version backup and restore (15+).
Creating backup jobs
Storage
If you are migrating from a previous version, your backup jobs will migrate on install including creating Filestore locations.
On a new install, the first step is to create a Filestore location. For information on doing this please see the Filestore documentation Here.
Backup Job Creation
| Step 1: Click on the "Add Backup" button |
| Step 2: Give your backup a name and description. |
| Step 3: Click the "Modules" button |
| Step 4a: Choose the modules to backup. You can click the box in the header to select all. Some modules will have their own settings which will be available by clicking the plus symbol. |
| Step 4b: Click "Save Changes" |
| Step4c: Add Custom directory to backup file. This is an important step if we need to add any custom data/files to backup file. By default it shows "ASTETCDIR" to include *_custom.conf files into the backup. We can remove this directory as well. Also by default, "call recording" files are not added to the Backup file. To add Call Recordings, we just need to add "__ASTSPOOLDIR__/monitor" directory as a Customer Directory. |
| Step 5: Select your notification preferences. If there is no email address notifications will be disabled. Note that notifications emails may be filtered as spam by your Mail Server/provider. If this happens you can typically whitelist the sender email address. |
| Step 6: Choose where to store the backup. You can select as many locations as desired. If you would like to save the backup jobs like <filestore-path>/<backup-job-name>/<backup-file> then enable "Append BackupJobName Directory into Storage path " option. By default this option is set to NO which means backup file will always store to "filestore" defined path i.e. "<filestore-path>/<backup-file>" |
| Step 7: Run this backup automatically. To do so, set enabled to "Yes" and select the schedule. Only the options available to the selection type will be enabled. By default these are all set randomly. |
| Step 8: Maintenance. Backups can be limited by number of runs to only keep the last 'X' backups. They can also be kept until they reach a certain age. For "Delete After Runs" 0 is unlimited. |
| Step 9: Warm Spare setup. See documentation HERE for warm spare setup. |
| Step 10: Save your backup. |
The grid
a | Select where you want to be from the tabs |
b | Button to create a new backup |
c | The name of your backup. |
d | A description of the backup |
e | Backup actions. Edit, Run, Show CLI command and Delete |
f | Search for your backup job in cases where you have many backups to filter through. |
Backup CLI:
You can copy the command from the ">_" icon and run the backup from an ssh session. A list is also available in the CLI by running 'fwconsole backup --list':
To run a backup use the "Backup ID" from the command above like this:
Restore
On a new install you can run the restore by uploading a backup file, or restore a previously saved backup on an existing install. From this window you can also download and delete stored backups.
After running or uploading a backup you will go to a confirmation screen.
Here you will see the description of the backup job to be run including the modules backed up, and choose whether to run the restore or go back to the restore page.
Restore CLI
You can restore the backup from the command line by using the '–restore' flag followed by the backup file name (depending on which directory you are located, you may want to use the full path of the backup file location, e.g. '/tmp/backup/remote-backup-1532726097.tar.gz').
Note the same warnings from the UI apply but there is no confirmation on the CLI.
Restore CLI Options which supports Current and Legacy version of backup file
There are a few options we have added to preserve the data on the server. When you apply the following options the data on the server will be preserved
--ignoremodules
Pas this option along with restoreto skip those modules from restore process. Multiple modules are allowed here separated by commas
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --ignoremodules=certman,backup--skipbindport
Pass this option along with restore command to preserver the bindport
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skipbindport--skipdns
Pass this option along with restore command to preserve DNS settings
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skipdns--skipremotenat
Pass this option along with restore command to preserve NAT settings
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skipremotenat--skiptrunksandroutes
Pass this option along with restore command to preserve existing trunk AND outbound route settings and not overwrite with restored settings.
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skiptrunkandroutes--skiprestorehooks
Pass this option along with restore command to skip post-hooks to be restored
e.g. fwconsole backup --restore 20230110-113623-1673372183-13.0.197.28-386235780.tgz --skiprestorehooks--restorelegacycdr
Pass this option along with restore command to restore CDR from legacy backup file,
e.g: fwconsole backup --restore 20230110-113623-1673372183-13.0.197.28-386235780.tgz --restorelegacycdr--restoresingle
Pass this option to select the module to restore
e.g. fwconsole backup --restore 20230110-113623-1673372183-13.0.197.28-386235780.tgz --restoresingle=endpoint--modules
Pass this option along with restore command to specify modules to restore, separated by commas
e.g. fwconsole backup --restore 20230110-113623-1673372183-13.0.197.28-386235780.tgz --modules core,restapps--useinfiledb
Pass this option along with restore command to restore Legacy backup using file based sqlite. By default system uses inmemory
e.g. fwconsole backup --restore 20230110-113623-1673372183-13.0.197.28-386235780.tgz --useinfiledb--skipchansipexts ( Only for Freepbx 17+)
Pass this option along with the restore command to skip legacy chan_sip extensions restore.
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skipchansipexts
--convertchansipexts2pjsip ( Only for Freepbx 17+)
Pass this option along with the restore command to convert chan_sip extensions to pjsip extensions during the restore process.
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --convertchansipexts2pjsip
--skipchansiptrunks ( Only for Freepbx 17+)
Pass this option along with the restore command to skip legacy chan_sip trunks during the restore process.
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skipchansiptrunks
--convertchansiptrunks2pjsip ( Only for Freepbx 17+)
Pass this option along with the restore command to convert chan_sip trunks to pjsip trunks during the restore process
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --convertchansiptrunks2pjsip
Note that all of the above flags can be used simultaneously when executing the restore command.
15+ CLI Commands
Please refer to fwconsole commands (15+)#Backup to know details about Backup module related CLI commands applicable for FreePBX 15+ systems.