MediaWikiServerTools

From BITPlan Wiki

OsProject[edit | edit source]

OsProject
edit
id  MediaWikiServerTools
state  active
owner  WolfgangFahl
title  MediaWikiServerTools
url  https://github.com/WolfgangFahl/MediaWikiServerTools
version  0.2.7
description  MediaWiki Server Management System - Apache Site management, SQL backups, cron-based backups
date  2026-07-05
since  2021-01-01
until  


Installation[edit source]

pip install MediaWikiServerTools
# alternatively if your pip is not a python3 pip
pip3 install MediaWikiServerTools 
# local install from source directory of MediaWikiServerTools 
pip install .

upgrade[edit source]

pip install MediaWikiServerTools  -U
# alternatively if your pip is not a python3 pip
pip3 install MediaWikiServerTools -U


Command line tools[edit | edit source]

Installed as console scripts (e.g. via pipx install MediaWikiServerTools):

  • tsite — Apache site / wiki-farm management and transfer
  • sqlbackup — dump MySQL/MariaDB databases
  • cronbackup — SQL backup + backup expiration, intended to be run from cron

cronbackup[edit | edit source]

Combines a database backup with retention-based expiration in a single command.

Operations[edit | edit source]

  • -b / --backup — dump the database(s) into <backup-dir>/today and create a dated archive sql_backup.YYYY-MM-DD.tgz (the archive is created automatically after the dump)
  • -e / --expire — apply the retention rules; dry-run unless -f is given
  • --all — expire, then backup
  • --database DB — back up a single database (default all)

Backend selection[edit | edit source]

  • --native — use the native client (sudo mysql / sudo mysqldump -u root); for hosts running MariaDB/MySQL directly
  • --docker CN — use the docker container CN via the mysqlr wrapper
  • --backup-user USER — OS user that owns the backup files (default backup)
  • explicit --mysql-root-cmd / --mysqldump-cmd override the backend selection
  • default when neither --native nor --docker is given: the legacy --container docker wrapper

Timeout and failure behaviour (0.2.7)[edit | edit source]

  • --timeout SECONDS — timeout for each SQL dump/command and the tar archive step (default 3600 s). Before 0.2.7 dumps were killed after the RunConfig default of 10 s and tar after 60 s — fatal for real databases (a 57 GB dump takes ~22 min, its tar ~40 min; size the timeout with headroom, e.g. --timeout 21600 for nightly production use).
  • Failures are loud: every failed dump, archive or expiration writes an ERROR line to the log and the process exits non-zero (before 0.2.7 a failed backup could exit 0 silently — issue #11).

Retention (pyExpireBackups)[edit | edit source]

Number of backups kept per bucket: --days (7) · --weeks (6) · --months (8) · --years (4).

Paths[edit | edit source]

  • --backup-dir — default /var/backup/sqlbackup (today/ holds the per-database dumps; tmp/ is the work area — both stay local)
  • --archive-dir — where the dated .tgz archives + expiration live; may be a remote/mounted path, e.g. an SSHFS-mounted storage box (defaults to --backup-dir)
  • --log-file — default /var/log/sqlbackup/sqlbackup-YYYY-MM-DD.log

Example — native host, archives on a storage box[edit | edit source]

# nightly: expire old archives, then back up all databases;
# dumps stay local, dated .tgz archives land on the SSHFS-mounted box
cronbackup --all -f --native --timeout 21600 \
  --backup-dir /var/backup/sqlbackup \
  --archive-dir /mnt/storage-box-vm2180/vm2180/sqlbackup \
  --days 14 --weeks 8 --months 24 --years 10

Dependencies[edit | edit source]

Requires pyExpireBackups (provides the expirebackups module used by cronbackup). This was added to the package dependencies in 0.2.6 — see issue #10.

History[edit | edit source]

  • 0.2.7 (2026-07-05, on main — no PyPI release yet): --timeout for dumps and tar; non-zero exit + ERROR log line on any failure (#11); stale version metadata fixed
  • 0.2.6 (2026-07-01): pyExpireBackups dependency declared (#10); --native/--docker/--backup-user; --archive-dir