Backup script

The 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.

Creating a Backup

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 /home/backups directory.

$ scripts/backup.sh /path/to/matrix /home/backups

Script Options

The script accepts the following options:

--verbose

View the progress of the script as it is running.

--database-only

Only backup the database data from your installation. This is useful if you already have another method of backing up your files.

--tostdout

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.

Oracle Databases

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 --remotedb=user@db.example.com

Or to backup to a specified directory:

$ .`/scripts`/backup.sh /path/to/matrix /path/to/backup/folder --remotedb=user@db.example.com

Restoring From a Backup

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.

Restoring the File System

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

Restoring the Database

The extraction of the backup file will create a file with a .dump extension. 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:

PostgreSQL

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

Oracle

The following commands will restore the Matrix database, where SID is the session ID, and dumpfile.dump is the name of the database dump file extracted from the backup file.

$ imp username/password@SID file=dumpfile.dump

© 2015- Squiz Pty Ltd