Backup Script

Last Updated: 04 Feb 2017

The backup.sh script can be run from the root directory to back up all files and database data from your Squiz Matrix installation to a single tar.gz file.

This script is located in the /scripts directory of your Squiz 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 progress of the script as it is running.

Bookmarks

Creating a Backup

It is recommended that regular backups should be taken of your Squiz Matrix system, especially when upgrading or making an significant system changes.

To create a backup of your Squiz 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 Squiz Matrix root directory. Please note that this process can be quite lengthy if you have a larger system with a large volume of content.

Alternatively, you can choose the directory to create the backup file in. 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 output of the script, send it to stdout. This is useful for piping though another program, eg gpg.

Oracle Databases

If your Squiz 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 Squiz 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 Squiz Matrix source files and file system data, replacing them with the 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 Squiz 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 Squiz Matrix database, where squiz_matrix is the name of your database, username is the user that Squiz 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 Squiz 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

Previous Chapter Next Chapter

The Latest

Let Us Know What You Think

Let us know if you spot any errors or if you have any ideas on how we can improve the Matrix Community Website.

Contact Squiz for Demo

Let us show you the true power of Squiz Matrix by giving you a personalised demonstration.