{ config, pkgs, ... }: let wikiDump = "/var/backup/wikidump.xml.gz"; mediawiki-maintenance = pkgs.runCommand "mediawiki-maintenance" { nativeBuildInputs = [ pkgs.makeWrapper ]; preferLocalBuild = true; } '' mkdir -p $out/bin makeWrapper ${config.services.phpfpm.pools.mediawiki.phpPackage}/bin/php $out/bin/mediawiki-maintenance \ --set MEDIAWIKI_CONFIG ${config.services.phpfpm.pools.mediawiki.phpEnv.MEDIAWIKI_CONFIG} \ --add-flags ${config.services.mediawiki.finalPackage}/share/mediawiki/maintenance/run.php ''; wiki-backup = pkgs.writeShellApplication { name = "wiki-backup"; runtimeInputs = [ pkgs.postgresql pkgs.util-linux ]; text = '' tmpdir=$(mktemp -d) cleanup() { rm -rf "$tmpdir"; } chown postgres:users "$tmpdir" mkdir -p /var/lib/mediawiki/backup/ runuser -u postgres -- pg_dump --format=custom --file "$tmpdir"/db mediawiki cp "$tmpdir"/db /var/lib/mediawiki/backup/db trap cleanup EXIT ''; }; old-wiki-restore = pkgs.writeShellApplication { name = "old-wiki-restore"; runtimeInputs = [ pkgs.postgresql pkgs.coreutils pkgs.util-linux mediawiki-maintenance ]; text = '' tmpdir=$(mktemp -d) cleanup() { rm -rf "$tmpdir"; } cd "$tmpdir" chown mediawiki:nginx "$tmpdir" rm -rf /var/lib/mediawiki-uploads install -d -m 755 -o mediawiki -g nginx /var/lib/mediawiki-uploads systemctl stop phpfpm-mediawiki.service runuser -u postgres -- dropdb mediawiki systemctl restart postgresql runuser -u postgres -- psql -c "ALTER DATABASE mediawiki OWNER TO mediawiki" systemctl restart mediawiki-init.service cat <