This guide will show you how to backup and restore your MySource Matrix system. This guide requires you to have shell access to the MySource Matrix application server to run the backup script and database queries.
If you do not have regular backups of your application and database servers, it is a good idea to use the MySource Matrix backup script to create backups of your MySource Matrix system. Backups should also be taken before attempting any upgrade, or whenever you're feeling nervous!
MySource Matrix comes with a backup script that creates a tar archive of the MySource Matrix source code, database and file system data.
Note that this procedure can take a long time if you have a lot of content in your MySource Matrix system.
$ cd /path/to/matrix $ ./scripts/backup.sh
By default, the MySource Matrix backup script will create a file based on the current date and time in the MySource Matrix root directory. You can choose a directory and filename other than the default if you need to.
For example, the following commands will backup your MySource Matrix installation to a file called mynewbackup.tar in the /home/backups directory.
cd /path/to/matrix $ ./scripts/backup.sh /home/backups/mynewbackup.tar
If your MySource Matrix system uses an Oracle database located on a separate server, the script must ssh to the database server and retrieve it. This is not required for PostgreSQL based systems.
The script will connect to the server, dump the database, and copy the resulting file back to the machine the script is being run from.
$ ./scripts/backup.sh --remotedb=user@db.example.com
Please note that the user you connect as must have exp in their path for the database dump to work correctly.
If you need to restore your system from a backup, you will need to remove your existing system and recreate it from the backup file.
This guide will show you how to restore a MySource Matrix system from a backup file, assuming the system is installed as /home/websites/mysource_matrix and the backup file is located at /home/backups/mybackup.tar.gz.
Restoring from backup will remove your existing system, including all existing file system and database data. You should consider backing-up your running MySource Matrix system before replacing it with an older backup to ensure no data is lost.
The following commands will delete your existing MySource Matrix source files and file system data and replace them with the backed -up copies.
$ cd /home/websites $ rm -rf mysource_matrix $ mkdir mysource_matrix $ cd mysource_matrix $ cp /home/backups/mybackup.tar.gz . $ tar -zxvf mybackup.tar.gz
The extraction of the backup file will have created a file with a .dump extension. This is the dump of your MySource Matrix database. Depending on the type of database you use, Postgres or Oracle, the command for restoring the database is different.
The following commands will restore your existing MySource Matrix database, assuming your database is called mysource_matrix.
$ dropdb -U postgres mysource_matrix $ createdb -U postgres -O username mysource_matrix $ psql -f dumpfile.dump mysource_matrix
where username is the user MySource Matrix uses to connect to its database and dumpfile.dump is the name of the database dump file that was extracted from the backup archive.
The following commands will restore your existing MySource Matrix database.
$ imp username/password@SID file=dumpfile.dump
where SID is the session id and dumpfile.dump is the name of the database dump file that was extracted from the backup archive.