+#!/bin/mksh
+#-
+# MediaWiki Plugin full dump/restore for FusionForge
+#
+# Copyright © 2013
+# Thorsten “mirabilos” Glaser <t.glaser@tarent.de>
+# All rights reserved.
+#
+# This file is part of FusionForge. FusionForge is free software;
+# you can redistribute it and/or modify it under the terms of the
+# GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the Licence, or (at your option)
+# any later version.
+#
+# FusionForge is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with FusionForge; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#-
+# Restores all pages and images from a file stored by mw-fulldump.
+# Passing not a file generated by mw-fulldump is Undefined Behaviour.
+#
+# Existing pages and files in the wiki will not be deleted; existing
+# pages with same names as those in the dump will be overwritten I guess.
+
+if [[ $# != 2 || $1 = *@([ ])* || ! -s $2 || \
+ ! -d /var/lib/gforge/plugins/mediawiki/wikidata/$1/images/. ]]; then
+ print -u2 'Syntax: mw-fullrestore tgtprojectname src.fulldump'
+ exit 255
+fi
+
+set -x
+set -e
+rm -rf "/var/lib/gforge/plugins/mediawiki/wikidata/$1/fulldump"
+(cd "/var/lib/gforge/plugins/mediawiki/wikidata/$1" && paxtar -xzf -) <"$2"
+cd "/var/lib/gforge/plugins/mediawiki/wikidata/$1/fulldump"
+/usr/share/gforge/plugins/mediawiki/bin/mw-wrapper.php "$1" \
+ importImages.php mfi/
+/usr/share/gforge/plugins/mediawiki/bin/mw-wrapper.php "$1" \
+ importDump.php df.xml
+cd ..
+rm -rf fulldump
+chown -R www-data:www-data \
+ "/var/lib/gforge/plugins/mediawiki/wikidata/$1/images"
+/usr/share/gforge/plugins/mediawiki/bin/mw-wrapper.php "$1" \
+ rebuildrecentchanges.php
+/usr/share/gforge/plugins/mediawiki/bin/mw-wrapper.php "$1" update.php --quick
+exit 0