Difference between revisions of "MediaWiki"

From NST Wiki
Jump to navigationJump to search
(Added copy of mediawiki backup script we use for this Wiki)
 
m (Adding MediaWiki)
Line 3: Line 3:
 
= Adding MediaWiki =
 
= Adding MediaWiki =
  
Use the '''System Patch Management''' page on the '''NST WUI''' to perform the initial installation. In addition:
+
Use the '''NST System Patch Management''' page on the '''NST WUI''' to perform the initial installation. In addition:
  
 
* You MUST setup the '''MySQL''' on the '''NST''' system.
 
* You MUST setup the '''MySQL''' on the '''NST''' system.
Line 9: Line 9:
 
* You will probably want to setup the '''ntpd''' to keep the system clock synchronized.
 
* You will probably want to setup the '''ntpd''' to keep the system clock synchronized.
  
* You will probably want to adjust the '''Apache''' web server configuration file to allow others access to the system (see [Apache Notes]).
+
* You will probably want to adjust the '''Apache''' web server configuration file to allow others access to the system (see [[Apache Notes]]).
  
 
= Backing Up The Wiki =
 
= Backing Up The Wiki =

Revision as of 08:27, 27 March 2007

This page contains some notes related to using a NST system as a MediaWiki server.

Adding MediaWiki

Use the NST System Patch Management page on the NST WUI to perform the initial installation. In addition:

  • You MUST setup the MySQL on the NST system.
  • You will probably want to setup the ntpd to keep the system clock synchronized.
  • You will probably want to adjust the Apache web server configuration file to allow others access to the system (see Apache Notes).

Backing Up The Wiki

Backing Up The Wiki Database

We use the following script to dump the SQL database containing the MediaWiki content. The script permits one to specify how many old backups to keep. We typically have cron run this script once a night and keep a weeks worth of backups immediately accessible.

#! /bin/bash

#
# nstwiki_mysql_backup --- PKB 2007

#
# Description: This script dumps the content of the MySQL Database
#              supporting the MediaWiki - NST WIKI
#
#        Note: Add symbolic soft link in /etc/cron.daily directory
#              for cron scheduling...

#
# Vars:
# =====
PKGDB="wikidb";
PKGSAVEDIR="/var/nst/backup/db";
PKGSAVEFILE="${PKGSAVEDIR}/nst${PKGDB}.sql.gz";

# How many backups to leave on system (must be 1 or larger)
declare -i PKGSAVECNT=7;

#
# Code:
# =====
. /etc/nst.conf || exit 1;

# Remove any unneed backups
declare -i i=${PKGSAVECNT};
while [ -f "${PKGSAVEDIR}/nst${PKGDB}${i}.sql.gz" ]; do
  /bin/rm -f "${PKGSAVEDIR}/nst${PKGDB}${i}.sql.gz";
  let i=i+1;
done

# Rename old backups (go from older to newer)
for ((i=PKGSAVECNT; i > 1;)); do
  g="${PKGSAVEDIR}/nst${PKGDB}${i}.sql.gz";
  i=$((i - 1));
  f="${PKGSAVEDIR}/nst${PKGDB}${i}.sql.gz";
  if [ -f "${f}" ]; then
    /bin/mv -f "${f}" "${g}";
  fi
done

# Rename last backup (if present)
if [ -f "${PKGSAVEFILE}" ]; then
  /bin/mv -f "${PKGSAVEFILE}" "${PKGSAVEDIR}/nst${PKGDB}1.sql.gz";
fi

# Dump database and save as current backup
[ -d "${PKGSAVEDIR}" ] || /bin/mkdir -p "${PKGSAVEDIR}" || exit 1;

nice /usr/bin/mysqldump \
  --host="127.0.0.1" \
  --user="root" \
  --password="${NSTCTMYSQLPASSWD}" \
  --add-drop-database \
  --add-drop-table \
  --databases "${PKGDB}" \
  | nice gzip -c \
  >| "${PKGSAVEFILE}";

#
# List backup compressed tar files...
printf "*** Listing backup directory: \"${PKGSAVEDIR}\"...\n";
/bin/ls -al --color=tty "${PKGSAVEDIR}";

#
# Terminate normally...
exit 0;

NOTE:

The above script is not suitable for a machine which is used for regular user accounts. This script is only acceptable for a system whose users will all have root access (the database password is passed on the command line and could be potentially captured in the output of a ps command). To secure this script for a public system, one would need to use expect in front of the mysql invocation.