Backup the database

From refbase

There are a number of ways to backup MySQL databases.

mysqldump

mysqldump is a command line program which ships with mysql.

mysqldump --all-databases -p > mysqldump.sql

will dump all databases (including, but not limited to the refbase literature database) to the file mysqldump.sql after you enter in a password.

In order to only backup the refbase literature database, you can use something like:

mysqldump MYSQL_DATABASE_NAME -uADMIN_USER_NAME -p --complete-insert --opt --default-character-set=CHARSET_NAME > refbase.sql

You must adjust the italic items within the above statement to suit your setup. MYSQL_DATABASE_NAME must match the value of the $databaseName variable in initialize/db.inc.php. For ADMIN_USER_NAME enter the name of the MySQL user that has full access to the refbase literature database. CHARSET_NAME must be either latin1 or utf8 depending on what character set you used on installation of your refbase database. Example: With root being the authorized user and literature as the name of your refbase latin1 database, your backup statement would read:

mysqldump literature -uroot -p --complete-insert --opt --default-character-set=latin1 > refbase.sql

The resulting backup file refbase.sql can be specified as SQL dump file when using install.php to setup a new refbase database. This is useful when you want to maintain local installations (such as on your personal laptop) that are occasionally synched with a refbase master database.

If you want to use mysqldump to backup your refbase database at regular intervals, you can use a shell script like the one below and have it executed as a cron job on your server:

#!/bin/sh
PATH=/usr/local/mysql/bin:$PATH
export PATH
datum=$(date +%Y%m%d)

cd /PATH/TO/REFBASE/BACKUPDIR

mkdir $datum
mkdir $datum/literature

chown mysql:root $datum/literature

mysqldump literature -uroot -pADMIN_USER_PWD --complete-insert --opt --default-character-set=latin1 > $datum/literature/refbase.sql

gzip -f $datum/literature/refbase.sql

cd /

In the above script, replace /PATH/TO/REFBASE/BACKUPDIR with the actual path to the refbase backup directory on your server. For ADMIN_USER_PWD, insert the password of the MySQL user that has full access to the refbase literature database (in this example, the MySQL root user). You may need to adopt other parts of the script such as the path to the mysql application or the name and charset of the refbase database.