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
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 " " 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.|
|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.|
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:
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.
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
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
Pass this option along with restore command to preserver the bindport
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skipbindport
Pass this option along with restore command to preserve DNS settings
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skipdns
Pass this option along with restore command to preserve NAT settings
e.g.: fwconsole backup --restore ./restorefile-15323456.tar.gz --skipremotenat
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
Pass this option along with restore command to skip post-hooks to be restored
e.g. fwconsole backup --restore 20230110-113623-1673372183-220.127.116.11-386235780.tgz --skiprestorehooks
Pass this option along with restore command to restore CDR from legacy backup file,
e.g: fwconsole backup --restore 20230110-113623-1673372183-18.104.22.168-386235780.tgz --restorelegacycdr
Pass this option to select the module to restore
e.g. fwconsole backup --restoresingle 20230110-113623-1673372183-22.214.171.124-386235780.tgz
Pass this option along with restore command to specify modules to restore, separated by commas
e.g. fwconsole backup --restore 20230110-113623-1673372183-126.96.36.199-386235780.tgz --modules core,restapps
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-188.8.131.52-386235780.tgz --useinfiledb
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.
To see what is in inside the backup files, you may check the manifest. The manifest is returned in JSON format and can be processed through automated methods. Note that backups are PHAR files and can be natively accessed through PHP's PharData class.