Backup and Restore (Generic)

SupportPal provides CLI commands for backing up and restoring installations.

Requirements

The following CLI applications must be installed on the server:

  • mysql
  • mysqldump
  • tar
  • gzip

They will be searched for via the PATH environment variable. If you're using Docker you're all set, other deployment methods may require the software to be installed.

The disable_functions php.ini directive must not be set.

MySQL Shell / MariaDB Shell (Optional)

If MySQL Shell (mysqlsh) is installed on a server using MySQL, or MariaDB Shell (mariadb-shell) on a server using MariaDB, it will be used to back up the database instead of mysqldump. The shell dumps and loads tables in parallel, which is considerably faster for large databases.

  • The shell must match the database server: mysqlsh only supports MySQL and mariadb-shell only supports MariaDB.
  • If the shell is not installed, or the shell backup fails, mysqldump is used instead. mysqldump and mysql are therefore still required.
  • The same shell is required to restore a backup that was created by it, see Restoring a Shell Backup.

Backup

SupportPal provides a command line interface to back up your entire instance, including:

  • Database
  • All files present in the installation path

Output Directory

All backups are generated in the storage/app/backups directory.

If you're using AWS S3 to store storage/app files, the backup will be automatically written to your S3 bucket. Upload speeds may be slow.

Usage

By default the command will backup the database and all files. See Additional Options to exclude the storage directory.

php app-manager/artisan app:backup
Additional Options

The following parameters are available on the command.

Option Description
--mysqldump-binary-path The command will try to automatically find mysqldump. If it returns an error, you can manually specify the absolute path to mysqldump. For example:
php app-manager/artisan app:backup --mysqldump-binary-path="C:\laragon\bin\mysql\mysql-5.7.24-winx64\bin\mysqldump"
--mysqlsh-binary-path The command will try to automatically find mysqlsh (MySQL) or mariadb-shell (MariaDB), and falls back to mysqldump if it cannot be found. You can manually specify the absolute path to the shell. For example:
php app-manager/artisan app:backup --mysqlsh-binary-path=/usr/bin/mysqlsh
The path must be to the shell that matches your database server.
--tar-binary-path The command will try to automatically find tar. If it returns an error, you can manually specify the absolute path to tar. For example:
php app-manager/artisan app:backup --tar-binary-path="C:\Program Files\Git\bin\tar.exe"
--minimal By default, all files are included in the backup. The --minimal option will exclude the storage/ directory (which stores ticket attachments, avatars, images and more). It is intended to improve the speed of the backup and reduce the amount of space used. We strongly recommend taking a full backup from time to time so that storage/ data can be restored.
--verify All backups contain an integrity file named .supportpal, the file contains hashes of all backed up files. When the --verify option is used we compare the file hashes to verify the integrity of the backup.
This option significantly increases the runtime and also size of the backup.
--no-compress Do not compress the backup file using gunzip.
--force Run the command non-interactively.

For further assistance, please refer to the help information which can be found by running:

php app-manager/artisan help app:backup

Database Backup Format

The backup contains a single database file, the name of which shows how it was created:

File Created By
database-<date>.sql.gz or .sql mysqldump
database-<date>.mysqlsh.tar MySQL Shell
database-<date>.mariadb-shell.tar MariaDB Shell

Troubleshooting

Slow Runtime

All files in the SupportPal directory are backed up, including those which are not shipped in the SupportPal archive. If it takes a long time to generate a backup please clean your SupportPal directory, so that it only contains files shipped by SupportPal.

The command will clone the filesystem to a temporary location and then use tar and gzip commands to back up that directory. This avoids errors when backing up files which are regularly changing - at the expense of 1X additional disk space and slower command speed. Unfortunately it is not possible to change the backup strategy.

Restore

SupportPal provides a command line interface to restore your entire installation. Be sure to test the complete restore process at least once before attempting to perform it in a production environment.

Usage

If a backup path is not provided, the command will automatically search the backup output directory for the latest backup.

php app-manager/artisan app:restore
Additional Options
Option Description
--mysql-binary-path The command will try to automatically find mysql. If it returns an error, you can manually specify the absolute path to mysql. For example:
php app-manager/artisan app:restore --mysql-binary-path=/bin/mysql
--mysqlsh-binary-path Only used when restoring a shell backup. The command will try to automatically find mysqlsh or mariadb-shell. If it returns an error, you can manually specify the absolute path to the shell. For example:
php app-manager/artisan app:restore --mysqlsh-binary-path=/usr/bin/mysqlsh
--gzip-binary-path The command will try to automatically find gzip. If it returns an error, you can manually specify the absolute path to gzip. For example:
php app-manager/artisan app:restore --gzip-binary-path=/bin/gzip
--tar-binary-path The command will try to automatically find tar. If it returns an error, you can manually specify the absolute path to tar. For example:
php app-manager/artisan app:restore --tar-binary-path="C:\Program Files\Git\bin\tar.exe"
--no-verify All backups contain an integrity file named .supportpal, the file contains hashes of all backed up files. By default, the command verifies that all commands are correctly restored. Use --no-verify to skip verification and improve the runtime speed.
--no-prune Keep files and directories that were created since the backup was generated, instead of removing them. For example:
php app-manager/artisan app:restore --no-prune
--force Run the command non-interactively.

For further assistance, please refer to the help information which can be found by running:

php app-manager/artisan help app:restore

Restoring a Shell Backup

A backup whose database file ends in .mysqlsh.tar or .mariadb-shell.tar was created by MySQL Shell or MariaDB Shell, and has additional requirements to restore:

  • The same shell must be installed on the server being restored to: mysqlsh for a .mysqlsh.tar backup, mariadb-shell for a .mariadb-shell.tar backup. The restore does not fall back to mysql.
  • The backup can only be restored to the same type of database server. A backup taken from MySQL cannot be restored to MariaDB, and vice versa. It can be restored to a different version of the same server.
  • The local_infile system variable must be enabled on the database server. If it is disabled, the command will enable it for the duration of the restore, which requires the database user to have permission to run SET GLOBAL. Otherwise, enable it manually before restoring.
  • The installation being restored to must be running a version of SupportPal that supports shell backups. Older versions fail with extracted file does not include a valid backup.

If you need a backup that can be restored without these requirements, for example to move between MySQL and MariaDB, create it on a server where the shell is not available so that mysqldump is used.