From c25c490677bcba2c2e9fee90db10594bd43f6982 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 5 Nov 2018 23:18:54 +0100 Subject: Importing Bitraf's mediawiki o Some improvements, reusing old backup scripts. --- ansible/roles/mediawiki/files/bin/mw-dump-backup | 9 +++++++++ ansible/roles/mediawiki/files/bin/mw-dump-db | 12 ++++++++++++ .../mediawiki/files/systemd/mediawiki-jobqueue.service | 13 +++++++++++++ .../roles/mediawiki/files/systemd/mediawiki-jobqueue.timer | 9 +++++++++ 4 files changed, 43 insertions(+) create mode 100644 ansible/roles/mediawiki/files/bin/mw-dump-backup create mode 100644 ansible/roles/mediawiki/files/bin/mw-dump-db create mode 100644 ansible/roles/mediawiki/files/systemd/mediawiki-jobqueue.service create mode 100644 ansible/roles/mediawiki/files/systemd/mediawiki-jobqueue.timer (limited to 'ansible/roles/mediawiki/files') diff --git a/ansible/roles/mediawiki/files/bin/mw-dump-backup b/ansible/roles/mediawiki/files/bin/mw-dump-backup new file mode 100644 index 0000000..eb98d7d --- /dev/null +++ b/ansible/roles/mediawiki/files/bin/mw-dump-backup @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail + +exec sudo -u www-data php /usr/share/mediawiki/maintenance/dumpBackup.php \ + --full \ + --include-files \ + --uploads \ + > /opt/mediawiki/backup/content-dump.xml diff --git a/ansible/roles/mediawiki/files/bin/mw-dump-db b/ansible/roles/mediawiki/files/bin/mw-dump-db new file mode 100644 index 0000000..5a6699a --- /dev/null +++ b/ansible/roles/mediawiki/files/bin/mw-dump-db @@ -0,0 +1,12 @@ +#!/bin/bash + +set -euo pipefail + +export PGHOST=$(sed -n 's,^.wgDBserver.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) +export PGUDATABASE=$(sed -n 's,^.wgDBname.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) +export PGUSER=$(sed -n 's,^.wgDBuser.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) +export PGPASSWORD=$(sed -n 's,^.wgDBpassword.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) +export PGPORT=$(sed -n 's,^.wgDBport.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) + +rm -rf /opt/mediawiki/backup/db +exec pg_dump -b --format directory -f /opt/mediawiki/backup/db diff --git a/ansible/roles/mediawiki/files/systemd/mediawiki-jobqueue.service b/ansible/roles/mediawiki/files/systemd/mediawiki-jobqueue.service new file mode 100644 index 0000000..a27891e --- /dev/null +++ b/ansible/roles/mediawiki/files/systemd/mediawiki-jobqueue.service @@ -0,0 +1,13 @@ +[Unit] +Description=MediaWiki job runner + +[Service] +WorkingDirectory=/opt/mediawiki/mediawiki/maintenance +# 900 is 15 minutes, this task is triggered every 15 minutes +ExecStart=/usr/bin/php runJobs.php --conf ../LocalSettings.php --maxtime=800 --wait +User=www-data +Group=www-data +StandardOutput=journal + +Nice=10 +OOMScoreAdjust=500 diff --git a/ansible/roles/mediawiki/files/systemd/mediawiki-jobqueue.timer b/ansible/roles/mediawiki/files/systemd/mediawiki-jobqueue.timer new file mode 100644 index 0000000..1d12500 --- /dev/null +++ b/ansible/roles/mediawiki/files/systemd/mediawiki-jobqueue.timer @@ -0,0 +1,9 @@ +[Unit] +Description=MediaWiki job runner timer + +[Timer] +OnBootSec=15min +OnUnitActiveSec=10m + +[Install] +WantedBy=timers.target -- cgit v1.2.3