Backup & Restore Module, FreePBX 16

TL;DR – I got deep in conversation with ChatGPT this afternoon to try and get some clear answers on how to back up FreePBX 16 as comprehensively as possible in case of a restore to a fresh Distro install. I asked some questions that I already knew the answer to, and some covered by the wiki, as I thought it might produce something helpful for others here for now and in the future. My backup for a fairly simple setup was 360MB. In summary, after selecting all the modules in Backup Items, I added the following Items and backed up to AWS S3 with no errors:

Edits: Placeholders should be written with a double underscore either side of the CAPITALS, like this: __CAPITALS__. For some reason it was stripping them out here. I have managed to put them back in using ` punctuation, which has hopefully made it a bit clearer. Sorry if I missed any, I have tried my best to copy and paste this from another source.

== choose == Directory:

__ASTETCDIR__
__ASTVARLIBDIR__/moh
__ASTVARLIBDIR__/sounds/custom
__ASTVARLIBDIR__/sounds/*/custom
__ASTSPOOLDIR__
__AMPWEBROOT__
__ASTLOGDIR__
__ASTERISK_DB__
/etc/asterisk/sip.conf
/etc/asterisk/extensions_additional.conf
/etc/asterisk/pjsip.conf
/etc/asterisk/pjsip_wizard.conf

What Directories do I need to include to fully backup FreePBX version 16?

To fully backup a FreePBX version 16 system, you will need to include the following directories:

  1. /etc/asterisk - This directory contains the Asterisk configuration files, which are necessary for your system to function properly.
  2. /var/lib/asterisk - This directory contains important data files for Asterisk, including voicemail messages, call recordings, and call detail records.
  3. /var/spool/asterisk - This directory contains the spool directories for voicemail, fax, and outgoing call files.
  4. /var/www/html/admin/modules - This directory contains the modules for FreePBX, including any custom modules you have installed.
  5. /var/www/html/admin/assets - This directory contains the assets for FreePBX, such as images and stylesheets.
  6. /var/log/asterisk - This directory contains the log files for Asterisk, which can be useful for troubleshooting issues.
  7. /root - This directory contains any custom scripts or configurations you have created, which may be necessary for restoring your system.

It’s important to note that the specific directories you need to backup may vary depending on your system configuration and any customizations you have made. It’s always a good idea to review the FreePBX documentation and consult with a qualified technician to ensure you are backing up all necessary data.

Ok, but why are they written like __ASTVARLIBDIR__/moh in the wiki?

The notation __ASTVARLIBDIR__ is a placeholder or variable that is used in the FreePBX wiki documentation to represent a system-specific directory path. When the FreePBX backup script runs, these variables are replaced with their corresponding directory paths, which are defined in the script or in the system configuration.

For example, __ASTVARLIBDIR__/moh is a placeholder for the directory path where the Music on Hold (MoH) files are stored. In most cases, the __ASTVARLIBDIR__ variable will be replaced with /var/lib/asterisk, which is the default directory path for Asterisk-related data files.

Using variables in this way makes it easier to write documentation that can be adapted to different system configurations without requiring the user to modify the documentation manually. It also helps to ensure that the backup script is able to locate the necessary files regardless of where they are stored on the system.

OK thanks, so tell me these again with the placeholder variables please?

Sure, here is the list of directories you need to include in a FreePBX version 16 backup, using the placeholder variables that are used in the FreePBX documentation:

  1. __ASTETCDIR__ - This directory contains the Asterisk configuration files: __ASTETCDIR__/asterisk
  2. __ASTVARLIBDIR__ - This directory contains important data files for Asterisk: __ASTVARLIBDIR__/asterisk
  3. __ASTSPOOLDIR__ - This directory contains the spool directories for voicemail, fax, and outgoing call files: __ASTSPOOLDIR__/asterisk
  4. __AMPWEBROOT__/admin/modules - This directory contains the modules for FreePBX, including any custom modules you have installed.
  5. __AMPWEBROOT__/admin/assets - This directory contains the assets for FreePBX, such as images and stylesheets.
  6. __ASTLOGDIR__ - This directory contains the log files for Asterisk: __ASTLOGDIR__/asterisk
  7. /root - This directory contains any custom scripts or configurations you have created, which may be necessary for restoring your system.

Again, it’s important to note that these directories are only placeholders, and the actual directory paths may vary depending on your system configuration and any customizations you have made. You should always consult the FreePBX documentation and consider consulting with a qualified technician to ensure you are backing up all necessary data.

Can I use __AMPWEBROOT__?

Yes, you can use __AMPWEBROOT__ in your FreePBX version 16 backup script to represent the web root directory where the FreePBX web interface is installed.

By default, the __AMPWEBROOT__ variable represents the directory path /var/www/html, where the FreePBX web files are located.

So, for example, to backup the modules directory, you would use the following path: __AMPWEBROOT__/admin/modules. This would be equivalent to /var/www/html/admin/modules on a default installation.

Using variables like __AMPWEBROOT__ can make your backup script more flexible and easier to maintain, since it automatically updates the directory path if the web root is moved to a different location or if you install FreePBX in a non-default location.

Just make sure to test your backup script thoroughly to ensure that it’s correctly capturing all of the necessary data.

What is __ASTAGIDIR__?

__ASTAGIDIR__ is a placeholder variable used in the FreePBX documentation to represent the directory path where Asterisk AGI scripts are stored.

AGI (Asterisk Gateway Interface) is an interface for adding custom functionality to Asterisk through the use of scripts written in languages such as Perl, Python, or PHP. These scripts can be used to perform a wide range of tasks, such as interacting with a database, sending SMS messages, or integrating with third-party APIs.

In FreePBX, AGI scripts are typically stored in the /var/lib/asterisk/agi-bin directory, which is the default directory for Asterisk AGI scripts. However, this directory path can be customized in the Asterisk configuration files, which is why the __ASTAGIDIR__ variable is used in the FreePBX documentation.

By using the __ASTAGIDIR__ variable in your backup script, you can ensure that your backup includes any custom AGI scripts that you have added to your system. Just make sure to verify the actual directory path on your system and update your backup script accordingly if necessary.

So I don’t need __ASTAGIDIR__ if I haven’t customised anything?

If you haven’t customized your Asterisk AGI scripts directory and are using the default /var/lib/asterisk/agi-bin directory, you don’t need to include __ASTAGIDIR__ in your FreePBX version 16 backup script.

The __ASTAGIDIR__ variable is mainly used for systems where the AGI scripts are stored in a custom directory other than the default one.

In a default FreePBX installation, the AGI scripts are stored in the /var/lib/asterisk/agi-bin directory and will be backed up as part of the __ASTVARLIBDIR__/asterisk backup directory.

However, if you have added custom AGI scripts to your system and stored them in a non-default directory, you will need to include that directory in your backup script, and use __ASTAGIDIR__ or the actual directory path in your script to ensure that the custom AGI scripts are included in your backup.

Can you list all of the placeholder variables that may have been customised?

Sure, here is a list of some of the most commonly used placeholder variables in FreePBX version 16, along with a brief description of their purpose:

  1. __ASTETCDIR__ - The directory path where Asterisk configuration files are stored.
  2. __ASTVARLIBDIR__ - The directory path where important data files for Asterisk are stored.
  3. __ASTSPOOLDIR__ - The directory path where spool directories for voicemail, fax, and outgoing call files are stored.
  4. __AMPWEBROOT__ - The directory path where the FreePBX web interface is installed.
  5. __ASTLOGDIR__ - The directory path where log files for Asterisk are stored.
  6. __ASTAGIDIR__ - The directory path where Asterisk AGI scripts are stored.
  7. __ASTERISK_DB__ - The path to the Asterisk database.
  8. __FOPWEBROOT__ - The directory path where the Flash Operator Panel (FOP) web interface is installed.
  9. __FW_FOPWEBROOT__ - The directory path where the FreePBX FOP module is installed.
  10. __FWLANG__ - The language used for FreePBX.

It’s important to note that these placeholder variables may have been customized on your specific system. For example, you may have configured Asterisk to store its data files in a non-default directory, or you may have installed FreePBX in a non-default location.

If you’re unsure of which variables have been customized on your system, you can check the FreePBX documentation or consult with a qualified technician to ensure that your backup script includes all of the necessary directories and files.

Can you tell me the approximate size in gigabytes for each of these?

The size of each directory in FreePBX version 16 can vary depending on the specific configuration and usage of your system. However, here is a rough estimate of the size for each of the directories you’ve mentioned:

  1. __ASTETCDIR__ - Typically very small, on the order of a few megabytes.
  2. __ASTVARLIBDIR__ - This directory can contain a significant amount of data, including call recordings, voicemail messages, and other Asterisk-related data. Depending on the usage of your system, this directory can range from a few gigabytes to tens of gigabytes.
  3. __ASTSPOOLDIR__ - Similar to the __ASTVARLIBDIR__ - the size of this directory can vary depending on the usage of your system. This directory typically contains voicemail and fax messages, as well as call files waiting to be processed by Asterisk.
  4. __AMPWEBROOT__ - This directory contains the files necessary for the FreePBX web interface, including themes, modules, and other web-related data. The size of this directory can range from a few hundred megabytes to several gigabytes.
  5. __ASTLOGDIR__ - This directory contains the log files for Asterisk. The size of this directory can vary greatly depending on the logging settings for Asterisk, but it typically ranges from a few megabytes to a few gigabytes.
  6. __ASTAGIDIR__ - This directory typically contains custom Asterisk AGI scripts, which can range in size depending on the number and complexity of the scripts.
  7. __ASTERISK_DB__ - The size of the Asterisk database can vary depending on the number of extensions and other configuration settings stored in the database. For a typical small to medium-sized deployment, the size of the database is usually less than 100 MB.
  8. __FOPWEBROOT__ - The size of this directory depends on whether you have installed and configured the Flash Operator Panel (FOP) web interface. If you haven’t installed FOP, the size of this directory is negligible.
  9. __FW_FOPWEBROOT__ - Similar to the __FOPWEBROOT__ directory, the size of this directory depends on whether you have installed and configured the FreePBX FOP module.
  10. __FWLANG__ - The size of this directory is negligible, as it typically only contains language-related files for FreePBX.

Which of these am I unlikely to need when restoring to a clean install of the Official FreePBX Distro?

When restoring to a clean install of the Official FreePBX Distro, you are unlikely to need the following directories:

  1. __ASTAGIDIR__ - Unless you have custom Asterisk AGI scripts that are essential to your system, you can exclude this directory.
  2. __FOPWEBROOT__ - If you haven’t installed the Flash Operator Panel (FOP) web interface, you can exclude this directory.
  3. __FW_FOPWEBROOT__ - If you haven’t installed the FreePBX FOP module, you can exclude this directory.
  4. __FWLANG__ - You can exclude this directory if you are restoring to the same language version as your original system.

However, it’s always a good idea to include all directories in your backup script, even if you think you may not need them. This ensures that you have a complete backup of your system, and it can save you time and effort in case you need to restore files that you didn’t think you needed.

Why don’t I need to specify Mysql like FreePBX version 14, or do I?

In FreePBX version 16, the configuration files for MySQL are typically located in the /etc directory, and the database name, username, and password are usually stored in the advancedsettings table in the Asterisk database. Therefore, you don’t need to specify the MySQL configuration separately when backing up FreePBX version 16.

However, it’s still a good idea to verify that your backup script includes the __ASTERISK_DB__ directory, which contains the Asterisk database where your FreePBX settings and configuration are stored, including the MySQL configuration.

It’s also important to note that if you have customized the MySQL configuration for your FreePBX installation, you may need to include the /etc/mysql or /etc/my.cnf directory in your backup script, depending on where your MySQL configuration files are stored.

What about these from FreePBX 14: /etc/wanpipe, /tftpboot, /etc/dahdi – Do I need them or where are they?

In FreePBX version 16, the configuration files for WANPIPE and Dahdi are typically located in the /etc directory, so you don’t need to include /etc/wanpipe or /etc/dahdi directories separately in your backup script.

As for the /tftpboot directory, this directory is typically used for provisioning devices and storing configuration files for network devices. If you have configured your FreePBX system to use TFTP for provisioning devices, you may want to include this directory in your backup script. However, if you’re not using TFTP for provisioning, you can exclude this directory.

It’s important to note that the directory structure and configuration files can vary depending on the specific installation and configuration of your FreePBX system. Therefore, it’s always a good idea to review your system’s configuration and make sure that all directories and configuration files necessary for restoring your system are included in your backup script.

Cool thanks. So all my Endpoint Manager settings for Sangoma P-Series and S-Series will be there without /tftpboot?

Yes, your Endpoint Manager settings for Sangoma P-Series and S-Series devices are stored in the Asterisk database and will be included in the __ASTERISK_DB__ directory of your backup, so you don’t need the /tftpboot directory to restore those settings.

The Endpoint Manager in FreePBX allows you to provision IP phones and configure various settings for those phones, including firmware updates, SIP configuration, and more. These settings are stored in the database and are typically backed up along with your other FreePBX settings.

However, if you have configured your Endpoint Manager to use TFTP for provisioning, you may want to include the /tftpboot directory in your backup script to ensure that the provisioning files are also backed up.

What is __AMPBIN__ and do I need it?

The __AMPBIN__ directory in FreePBX contains various binary files used by the FreePBX web interface and command-line tools. These files include various scripts, utilities, and executables used by FreePBX and its modules.

Examples of files that you can find in __AMPBIN__ include:

  • fwconsole - a command-line utility used to manage various aspects of FreePBX.
  • amportal - a script used to start and stop FreePBX services.
  • php - the PHP executable used by FreePBX.

Whether or not you need to include the __AMPBIN__ directory in your backup script depends on your specific use case. If you have made customizations to the FreePBX system or installed additional modules that rely on custom scripts, you may want to include this directory to ensure that those custom scripts are backed up.

However, if you have not made any customizations to the FreePBX system or installed additional modules that rely on custom scripts, you can exclude this directory from your backup script.

Very helpful, thanks. What is __AMPSBIN__ and do I need it?

The __AMPSBIN__ directory in FreePBX contains various system-level binaries and utilities used by the FreePBX system. These files include various Linux system utilities and libraries required by FreePBX and its modules to run properly.

Examples of files that you can find in __AMPSBIN__ include:

  • yum - the package manager used by the FreePBX system to install and manage software packages.
  • systemctl - the utility used by the FreePBX system to manage system services.
  • openssl - the OpenSSL library used by the FreePBX system to manage SSL/TLS certificates.

Whether or not you need to include the __AMPSBIN__ directory in your backup script depends on your specific use case. If you have made customizations to the FreePBX system or installed additional modules that rely on custom system-level utilities or libraries, you may want to include this directory to ensure that those custom utilities and libraries are backed up.

However, if you have not made any customizations to the FreePBX system or installed additional modules that rely on custom system-level utilities or libraries, you can exclude this directory from your backup script.

Do I need to include __ASTVARLIBDIR__ or do I just include __ASTVARLIBDIR__/moh, __ASTVARLIBDIR__/sounds/custom, and __ASTVARLIBDIR__/sounds/*/custom?

Whether or not you need to include the __ASTVARLIBDIR__ directory in your backup script depends on your specific use case.

The __ASTVARLIBDIR__ directory contains various data files and directories used by Asterisk and its modules, such as voicemail messages, call recordings, and configuration files.

If you have customized any of the data files or directories in this directory, or if you are using third-party modules that store data in this directory, you may want to include it in your backup script to ensure that all necessary data is backed up.

However, if you have not made any customizations to the files in this directory, you may be able to exclude it from your backup script and just include the specific directories and files you mentioned __ASTVARLIBDIR__/moh, __ASTVARLIBDIR__/sounds/custom, and __ASTVARLIBDIR__/sounds/*/custom), which contain custom Music on Hold files and custom sound files.

In summary, it depends on your specific use case and whether you have made any customizations or are using third-party modules that store data in the __ASTVARLIBDIR__ directory.

What is the difference between __ASTVARLIBDIR__/sounds/custom and __ASTVARLIBDIR__/sounds/*/custom?

The difference between __ASTVARLIBDIR__/sounds/custom and __ASTVARLIBDIR__/sounds/*/custom is that __ASTVARLIBDIR__/sounds/custom contains custom sounds that are applied globally, while __ASTVARLIBDIR__/sounds/*/custom contains custom sounds that are applied to specific languages or dialects.

Specifically, __ASTVARLIBDIR__/sounds/custom is the directory where you can store custom sounds that will be used by all languages and dialects. On the other hand, __ASTVARLIBDIR__/sounds/*/custom is a set of directories where you can store custom sounds that will be used by specific languages and dialects. The asterisk (*) in __ASTVARLIBDIR__/sounds/*/custom is a wildcard character that represents any language or dialect directory.

For example, if you have custom sounds for the English language, you would store them in __ASTVARLIBDIR__/sounds/en/custom. Similarly, if you have custom sounds for the Spanish language, you would store them in __ASTVARLIBDIR__/sounds/es/custom. By using language-specific directories, you can ensure that the appropriate custom sounds are used for each language or dialect.

In summary, __ASTVARLIBDIR__/sounds/custom contains custom sounds that are applied globally, while __ASTVARLIBDIR__/sounds/*/custom contains custom sounds that are applied to specific languages or dialects.

Got it thanks. So in summary, if I want a full backup and have carried out very little customisation, perhaps just some sound files, I can use the following:

__ASTETCDIR__
__ASTVARLIBDIR__/moh
__ASTVARLIBDIR__/sounds/custom
__ASTVARLIBDIR__/sounds/*/custom
__ASTSPOOLDIR__
__AMPWEBROOT__
__ASTLOGDIR__
__ASTERISK_DB__
/root

Is there anything I have missed?

Based on what you’ve described, the directories you listed should cover most of the data you would want to back up for a basic FreePBX system. However, here are a few additional directories you may want to consider including:

  • __ASTMODDIR__: This directory contains all of the Asterisk modules, including third-party modules you may have installed. If you have any custom modules or modules that are not included in the FreePBX distribution, you may want to include this directory in your backup.
  • __AMPBIN__: This directory contains FreePBX scripts and binaries. If you have made any customizations to FreePBX or have added any custom scripts, you may want to include this directory in your backup.
  • /etc/asterisk/iax.conf: This file contains configuration settings for the IAX protocol, which is used for VoIP communication. If you are using IAX, you may want to include this file in your backup.
  • /etc/asterisk/sip.conf: This file contains configuration settings for the SIP protocol, which is also used for VoIP communication. If you are using SIP, you may want to include this file in your backup.
  • /etc/asterisk/extensions_additional.conf: This file contains additional dialplan rules generated by FreePBX. If you have made any customizations to your dialplan or have added any custom dialplan rules, you may want to include this file in your backup.

Again, whether or not you need to include these directories in your backup script depends on your specific use case and whether you have made any customizations or are using third-party modules that store data in these directories.

What about PJSIP?

If you are using the PJSIP protocol for VoIP communication, you may want to consider including the following directories in your backup:

  • /etc/asterisk/pjsip.conf: This file contains configuration settings for the PJSIP protocol. If you have made any customizations to the PJSIP settings or have added any custom endpoints, you may want to include this file in your backup.
  • /etc/asterisk/pjsip_wizard.conf: This file contains the configurations for the PJSIP endpoints created through the FreePBX PJSIP wizard. If you have used the PJSIP wizard to create custom endpoints, you may want to include this file in your backup.

As with the other directories, whether or not you need to include these directories in your backup script depends on your specific use case and whether you have made any customizations or are using custom PJSIP endpoints that store data in these directories.

__ASTETCDIR__
__ASTVARLIBDIR__/moh
__ASTVARLIBDIR__/sounds/custom
__ASTVARLIBDIR__/sounds/*/custom
__ASTSPOOLDIR__
__AMPWEBROOT__
__ASTLOGDIR__
__ASTERISK_DB__
/root
/etc/asterisk/sip.conf
/etc/asterisk/extensions_additional.conf
/etc/asterisk/pjsip.conf
/etc/asterisk/pjsip_wizard.conf

Yes, including those directories and files you listed would provide a more comprehensive backup of your FreePBX installation, including your SIP, PJSIP, and extension settings.

It’s important to note that restoring these configurations on a different installation or version of FreePBX could potentially cause compatibility issues, so make sure to test your backups thoroughly before restoring them on a different system.

And I specify each of these as “Directory”, (not “File”?) in the Backup & Restore module of FreePBX 16?

Yes, that’s correct. In the Backup & Restore module of FreePBX 16, you should specify these as directories, not files.

To do so, go to the “Directories” section of the Backup & Restore module and click “Add Directory”. Then enter the path to the directory you want to include in your backup, and click “Save”. Repeat this process for each directory you want to include in your backup.

And I definitely need /root?

Including the /root directory in your backup is optional, as it contains files that are specific to your root user and are unlikely to affect your FreePBX system as a whole. However, if you have any important files in your root user’s home directory, you may want to include it in your backup just to be safe.

If you’re unsure about what files are in your root user’s home directory and whether they need to be backed up, you can check the contents of the directory by running the following command in the terminal:

# ls -la /root

This will list all of the files and directories in the root user’s home directory, along with their permissions and other information.

So if I haven’t customised anything here, I probably don’t need /root?

If you haven’t customized anything in the /root directory, then you probably don’t need to include it in your backup.

The /root directory typically contains configuration files and other data that are specific to the root user on your system. These files are generally not related to your FreePBX configuration, so they don’t need to be backed up unless you have customized them in some way.

However, it’s always a good idea to review the contents of the /root directory and decide for yourself whether any of the files there are important to you and should be included in your backup.

Ok, got it. Thanks for all your help.

You’re welcome! I’m glad I could help. If you have any more questions, feel free to ask.

2 Likes

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