backup.sh script can be run from the root directory to back up all files and database data from your Matrix installation to a single tar.gz file.
This script is located in the
/scripts directory of your Matrix system.
You can enter the optional argument
--database-only to only backup the database data from your installation.
This is useful if you already have another method of backing up your files.
You can use the
--verbose option argument to view the script’s progress as it is running.
It is recommended that regular backups should be taken of your Matrix system, especially when upgrading or making significant system changes.
To create a backup of your Matrix system, use the
backup.sh script, as follows:
$ scripts/backup.sh /path/to/matrix
By default, this script will create a backup file based on the current date and time in the Matrix root directory.
|This process can be quite lengthy if you have an extensive system with a large volume of content.|
Alternatively, you can choose the directory in which to create the backup file.
For example, the following command will create a backup in the
$ scripts/backup.sh /path/to/matrix /home/backups
The script accepts the following options:
View the progress of the script as it is running.
Only backup the database data from your installation. This is useful if you already have another method of backing up your files.
Instead of creating a file for the script’s output, send it to
stdout. This is useful for piping through another program, for example, GPG.
If your Matrix installation is on an Oracle database located on a separate server, the
backup.sh script will require you to make an SSH connection to the database server.
This is not required for PostgresSQL-based systems.
$ scripts/backup.sh /path/to/matrix --firstname.lastname@example.org
Or to backup to a specified directory:
$ .`/scripts`/backup.sh /path/to/matrix /path/to/backup/folder --email@example.com
If your system is corrupt or not working correctly, you may need to restore your Matrix installation from a previously created backup.
Restoring from a backup will remove your existing system, including all file systems and database data. You should consider backing up your current system before replacing it with an old backup to ensure no data is lost.
The following commands will delete your existing Matrix source files and file system data, replacing them with backed-up copies.
In this example, we are backing up from the
mybackup.tar.gz file in the
home/backups directory using the database name squiz_matrix.
$ cd home/websites $ rm -rf squiz_matrix $ mkdir squiz_matrix $ cd squiz_matrix $ cp home/backups/mybackup.tar.gz . $ tar -zxvf mybackup.tar.gz
The extraction of the backup file will create a file with a
This is the dump of your Matrix database.
Depending on the database type your system is installed on, the command for restoring the database is as follows:
The following commands will restore the Matrix database, where squiz_matrix is the name of your database, the username is the user that Matrix uses to connect to its database, and
dumpfile.dump is the name of the database dump file extracted from the backup file.
$ dropdb -U postgres squiz_matrix $ createdb -U postgres -O username -E UTF8 squiz_matrix $ createlang -U postgres plpgsql squiz_matrix $ psql -U postgres -f dumpfile.dump squiz_matrix