Documentation

Good practices

Keeping up-to-date

For security reasons it is very important that your board is kept up-to-date. For more information on checking for updates see checking for updates, for help installing them see Upgrading.

Backing up

Once of the most important, but often ignored, practices is keeping a regular backup of your forum. It is impossible to estimate when disaster may strike, whether it be hardware failure, file corruption, human error or anything else.

It is important to note that keeping a backup of the files you uploaded is not enough, you also need to regularly backup your forum database.

Manual backup

  1. Take a copy of all the forum files.
    • Using an FTP client.
    • Using SCP: scp -r user@example.org:~/forums/ ./
    • As a gzipped tar archive: tar -czvf backup.tar.gz ~/forums/
  2. Take a copy of the database.
    • For MySQL:
      • Using mysqldump: mysqldump -u <user> -p <db name> | gzip -f > backup.sql.gz (where <user> is your MySQL username and <db name> is your forum database name)
    • For PostgreSQL:
      • Using pg_dump: pg_dump -U <user> <db name> | gzip -f > backup.sql.gz (where <user> is your PostgreSQL username and <db name> is your forum database name)
    • For SQLite:
      • Simply take a copy of your database file as in step 1.

Note: Unless you are comfortable with *nix I would recommend using a FTP client and phpMyAdmin/PHPPgAdmin.

Automated backup

The main problem with backing up is usually people get lazy and stop taking regular backups. The obvious solution is to use an automated backup procedure.

Some web hosts provide easy to use facilities for this in their control panels, so first of all have a look there, but remember you need both the files and the database backed up.

In-case your host does not provide any kind of backup facility, the script below can be used along with a crontab to perform scheduled backups. Another useful tool which can create snapshots of a directory without wasting large amounts of disk space is rsnapshot.

Note: The following is not a stand alone script, it assumes you have rsync already installed and setup as a daemon on a remote server somewhere. It also assumes you are using MySQL, and have mysqlhotcopy installed. Unless you can understand what the script does I would not recommend trying to use it.

mysqlhotcopy will not back up InnoDB tables. If you have InnoDB tables, do not rely on this script!

backup.sh
#!/bin/bash
 
# Rsync settings
RSYNC_HOST="backup.example.org"
RSYNC_USER="backup"
RSYNC_PASSFILE="/root/rsync.secret"
 
# MySQL settings
MYSQL_USER="backup"
MYSQL_PASS="!!changeme!!"
MYSQL_DATADIR="/var/lib/mysql"
 
# ------------------- BACKUP FILES ------------------- #
 
# backup the www folder
rsync -avzL --delete --password-file=$RSYNC_PASSFILE /var/www/* rsync://$RSYNC_USER@$RSYNC_HOST/$RSYNC_USER/www
 
# ------------------- BACKUP MYSQL ------------------- #
 
# Create a temp directory to use
TMP_DIR="/tmp/mysql_`date +%s`"
mkdir $TMP_DIR
 
# Enter the MySQL data directory
cd $MYSQL_DATADIR
 
# Find each MySQL table there is (each has it's own folder)
for DB in `find * -type d -prune`
do
        mysqlhotcopy --method=cp --user=$MYSQL_USER --password=$MYSQL_PASS $DB $TMP_DIR
done
 
# rsync TMP_DIR
rsync -avzL --delete --password-file=$RSYNC_PASSFILE $TMP_DIR/* rsync://$RSYNC_USER@$RSYNC_HOST/$RSYNC_USER/mysql
 
# remove TMP_DIR
rm -rf $TMP_DIR