Difference between revisions of "Restore.sh"

From PKC
Jump to navigation Jump to search
(Created page with "On a running instance of bkoo/MediaWiki:1.35, the following backup.sh script can be launched using the following instruction: <SyntaxHighlight> docker exec dockerizedwiki...")
 
 
Line 1: Line 1:
On a running instance of [[bkoo/MediaWiki:1.35]], the following backup.sh script can be launched using the following instruction:
On a running instance of [[bkoo/MediaWiki:1.35]], the following restore.sh script can be launched using the following instruction:


<SyntaxHighlight>
<SyntaxHighlight>
docker exec dockerizedwiki_mediawiki_1 /var/www/html/extensions/BackupAndRestore/backup.sh
docker exec dockerizedwiki_mediawiki_1 /var/www/html/extensions/BackupAndRestore/restore.sh
</SyntaxHighlight>
</SyntaxHighlight>


Line 15: Line 15:
# Define the file name format and variable name
# Define the file name format and variable name
FilePrefix="XLP"
FilePrefix="XLP"
DATE=$(date +"%m-%d-%Y_%H_%M_%S_%Z")
FilePostfix=".xml"
FilePostfix=".xml"
# Construct the file name string
FileName=$FilePrefix$DATE$FilePostfix


# Define the latest literal string
# Define the latest literal string
LATEST="LATEST"
LATEST="LATEST"


# If the XLPDATALATEST.xml doesn't exist in the specified directory, dump all data to the file with that name.
# if [ ! -e $ResourceBasePath/images/$FilePrefix$LATEST$FilePostfix ]; then
# Construct the file name string
# Construct the file name string
FileName=$FilePrefix$LATEST$FilePostfix
FileName=$FilePrefix$LATEST$FilePostfix
# fi


echo "Ready to dump all textual data into " $ResourceBasePath/images/$FileName
echo "Ready to import all textual data from " $ResourceBasePath/images/$FileName


php $ResourceBasePath/maintenance/dumpBackup.php --full --quiet >$ResourceBasePath/images/$FileName
php $ResourceBasePath/maintenance/importDump.php < $ResourceBasePath/images/$FileName


# Before running the dumpUpLoads.php with the sed instructions, one must first change directory to the /var/www/html location.
# Load images from the UploadedFiles location.
cd $ResourceBasePath
cd $ResourceBasePath
php $ResourceBasePath/maintenance/dumpUploads.php   | sed 's~mwstore://local-backend/local-public~./images~'    | xargs cp -t $ResourceBasePath/images/UploadedFiles/
php $ResourceBasePath/maintenance/importImages.php $ResourceBasePath/images/UploadedFiles/


</SyntaxHighlight>
</SyntaxHighlight>

Latest revision as of 04:12, 26 March 2021

On a running instance of bkoo/MediaWiki:1.35, the following restore.sh script can be launched using the following instruction:

docker exec dockerizedwiki_mediawiki_1 /var/www/html/extensions/BackupAndRestore/restore.sh

The original Bash script can be seen here:

#! /bin/bash

# This variable should have the same value as the variable $wgResourceBasePath in LocalSettings.php
ResourceBasePath="/var/www/html"

# Define the file name format and variable name
FilePrefix="XLP"
FilePostfix=".xml"

# Define the latest literal string
LATEST="LATEST"

# Construct the file name string
FileName=$FilePrefix$LATEST$FilePostfix

echo "Ready to import all textual data from " $ResourceBasePath/images/$FileName

php $ResourceBasePath/maintenance/importDump.php < $ResourceBasePath/images/$FileName

# Load images from the UploadedFiles location.
cd $ResourceBasePath
php $ResourceBasePath/maintenance/importImages.php $ResourceBasePath/images/UploadedFiles/