{ 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-restore = pkgs.writeShellApplication { name = "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 <