From: Thorsten Glaser Date: Mon, 29 Apr 2013 08:55:05 +0000 (+0200) Subject: add helper scripts to dump/restore pages+images+files of a wiki X-Git-Tag: v5.2.2~15^2~4 X-Git-Url: https://scm.fusionforge.org/anonscm/gitweb?p=fusionforge%2Ffusionforge.git;a=commitdiff_plain;h=1f5bd625f047460bdab87f87df9dd0ba25a4e9be;ds=sidebyside add helper scripts to dump/restore pages+images+files of a wiki --- diff --git a/src/plugins/mediawiki/bin/mw-fulldump b/src/plugins/mediawiki/bin/mw-fulldump new file mode 100644 index 0000000000..2ed27b5983 --- /dev/null +++ b/src/plugins/mediawiki/bin/mw-fulldump @@ -0,0 +1,55 @@ +#!/bin/mksh +#- +# MediaWiki Plugin full dump/restore for FusionForge +# +# Copyright © 2013 +# Thorsten “mirabilos” Glaser +# 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. +#- +# Dumps all pages of a FusionForge MediaWiki plugin project, with their +# complete history, plus all images and other files, into a tarball to +# be imported into another wiki by mw-fullrestore. + +if [[ $# != 1 || $1 = *@([ ])* || -e $1.fulldump || \ + ! -d /var/lib/gforge/plugins/mediawiki/wikidata/$1/images/. ]]; then + print -u2 'Syntax: mw-fulldump projectname' + exit 255 +fi + +wd=$PWD +set -x +set -e +rm -rf "/var/lib/gforge/plugins/mediawiki/wikidata/$1/fulldump" +mkdir "/var/lib/gforge/plugins/mediawiki/wikidata/$1/fulldump" +cd "/var/lib/gforge/plugins/mediawiki/wikidata/$1/fulldump" +/usr/share/gforge/plugins/mediawiki/bin/mw-wrapper.php "$1" \ + dumpUploads.php >mf1.txt +sed \ + "smwstore://local-backend/local-public/var/lib/gforge/plugins/mediawiki/wikidata/$1/images" \ + mf2.txt +mkdir mfi +if [[ -s mf2.txt ]]; then + ln $(df.xml +rm -f mf?.txt +cd .. +paxtar -M dist -czf "$wd/$1.fulldump" fulldump +rm -rf fulldump +exit 0 diff --git a/src/plugins/mediawiki/bin/mw-fullrestore b/src/plugins/mediawiki/bin/mw-fullrestore new file mode 100644 index 0000000000..6d2f00572a --- /dev/null +++ b/src/plugins/mediawiki/bin/mw-fullrestore @@ -0,0 +1,52 @@ +#!/bin/mksh +#- +# MediaWiki Plugin full dump/restore for FusionForge +# +# Copyright © 2013 +# Thorsten “mirabilos” Glaser +# 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