Media Wiki Restoration: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* https://www.mediawiki.org/wiki/Manual:Restoring_a_wiki_from_backup
* https://www.mediawiki.org/wiki/Manual:Upgrading
* https://gerrit.wikimedia.org/g/mediawiki/core/+/REL1_35/UPGRADE
* https://www.mediawiki.org/wiki/Manual:Moving_a_wiki
=Internal=
=Internal=
* [[Media_Wiki_Operations#Restoration|Media Wiki Operations]]
* [[Media_Wiki_Operations#Restoration|Media Wiki Operations]]
=Overview=
=Overview=
This procedure documents restoration of a site instance backed up with the [[Media_Wiki_Backup#Overview|Media Wiki Backup]] procedure. Restoration implies performing a full new installation of the latest LTS version as a prerequisite, as described here [[Media Wiki Installation#Overview|Media Wiki Installation]] and then executing the database restoration script.
This procedure documents restoration of a Media Wiki site instance backed up with the tooling described in [[Media_Wiki_Backup_Automation#Overview|Media Wiki Backup Automation]]. Restoration implies performing a new full installation of the latest LTS version as a prerequisite, as described here [[Media Wiki Installation#Overview|Media Wiki Installation]] followed by state restoration by executing the restoration script <code>mediawiki-restore</code>. The state restoration procedure is described by this article.
 
=Pull the Backup File from Storage=
 
The backup files are stored on <code>rackstation</code> in <code>/volume4/backups/kb.novaordis.com</code>. The backup file is named similar to <code>2023.12.30-03.00.01-not500-kb.novaordis.com-backup.tgz</code>.
 
=Check Preconditions=
=Check Preconditions=
At this point, the new Media Wiki installation procedure should have created a temporary database and database user, defined here: [[Media_Wiki_Installation#Instance_Restoration|Media Wiki Installation &#124; Instance Restoration]]. At the end of the restoration, both the temporary database and the database users will be deleted. Verify that they are indeed created, and they are the only Media Wiki database and database user:
At this point, the new Media Wiki installation procedure should have created a transient database and database user, necessary for instance initialization and setup, as defined here [[Media_Wiki_Installation#Instance_Restoration|Media Wiki Installation &#124; Instance Restoration]]. At the end of the restoration, both the transient database and the database users will be deleted as described in [[#Transient_Database_Cleanup|Transient Database Cleanup]]. Verify that they are indeed created, and they are the only Media Wiki database and database user:
{{Internal|mysql Command Line Client#Connect|Connect to MariaDB}}
{{Internal|mysql Command Line Client#Connect|Connect to MariaDB}}
<syntaxhighlight lang='sql'>
<syntaxhighlight lang='sql'>
Line 13: Line 25:
=Restore the Database=
=Restore the Database=


Use the restoration script to create the database and the database user being restored, then restore the database.
Use the restoration script in <code>--database-only</code> mode. The script will request the local MariaDB database password root at <code>stdin</code>.


<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
backup-system/mediawiki-restore -v \
backup-system/mediawiki-restore --database-only /Users/ovidiu/tmp/2024.01.01-03.00.02-not500-kb.novaordis.com-backup.tgz /opt/brew/var/www/mediawiki-1.39.6  
  /Users/ovidiu/tmp/2023.12.29-03.00.01-not500-kb.novaordis.com-backup.tgz \
  /opt/brew/var/www/mediawiki-1.39.6 -d /Users/ovidiu/tmp/post-install
</syntaxhighlight>
</syntaxhighlight>
<font color=darkkhaki>Modify the script to be able to stop after restoring the database.</font>


At this point, the MariaDB instance must contain both the temporary and the production database and database users.
At this point, the MariaDB instance must contain both the temporary and the production database and database users.
Line 30: Line 38:
</syntaxhighlight>
</syntaxhighlight>


Collect database user, password and database name.
=(Optional) Update the Database=
 
If the Media Wiki version of the instance we are using as source is older than the Media Wiki version we are restoring into, perform a database upgrade. From the target Media Wiki instance root directory:
Update <code>/opt/brew/var/www/mediawiki-1.39.6/LocalSettings.php</code>:
<syntaxhighlight lang='bash'>
 
cd /opt/brew/var/www/mediawiki-1.35.14
<syntaxhighlight lang='php'>
php maintenance/update.php
$wgDBname = "novaordis_wiki";
</syntaxhighlight>
$wgDBuser = "novaordis_wiki";
<font size=-2>
$wgDBpassword = "...";
MediaWiki 1.35.14 Updater
Your composer.lock file is up to date with current dependencies!
Going to run database updates for novaordis_wiki
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds (skip this countdown with --quick) ... 0
...have ipb_id field in ipblocks table.1
...
el_id 10010 - 10402 of 10402
Done, 24 rows updated, 8 deleted.
Purging caches...done.
 
Done in 2 min 25 s.
</font>
=Start <tt>httpd</tt> and Test=
<syntaxhighlight lang='bash'>
brew services start httpd
</syntaxhighlight>
</syntaxhighlight>
The new database content should be accessible.
=Restore Images=
Use the restoration script in <code>--image-files-only</code> mode. The script will restore the <code>images</code> directory content.


=Upgrade the Database=
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
php maintenance/update.php
backup-system/mediawiki-restore --image-files-only /Users/ovidiu/tmp/2024.01.01-03.00.02-not500-kb.novaordis.com-backup.tgz /opt/brew/var/www/mediawiki-1.39.6
</syntaxhighlight>
</syntaxhighlight>
=Work in Progress=
<font color=darkkhaki><code>mediawiki-restore</code> has logic to restore keys and certificates, and compare the old and new installation to report the differences. Document that.</font>


=Post Restoration=
=Post Restoration=
 
==Transient Database Cleanup==
==Database Cleanup==
Drop the transient database and user:
 
Drop the temporary database and user:
<syntaxhighlight lang='sql'>
<syntaxhighlight lang='sql'>
DROP DATABASE tmp_mediawiki_db;
DROP DATABASE tmp_mediawiki_db;
Line 55: Line 83:
COMMIT;
COMMIT;
</syntaxhighlight>
</syntaxhighlight>
=TO DEPLETE=
<font color=darkkhaki>
DEPLETE and INTEGRATE: [[Restoring a Wiki into the Same or Newer MediaWiki Version]]

Latest revision as of 19:17, 1 January 2024

External

Internal

Overview

This procedure documents restoration of a Media Wiki site instance backed up with the tooling described in Media Wiki Backup Automation. Restoration implies performing a new full installation of the latest LTS version as a prerequisite, as described here Media Wiki Installation followed by state restoration by executing the restoration script mediawiki-restore. The state restoration procedure is described by this article.

Pull the Backup File from Storage

The backup files are stored on rackstation in /volume4/backups/kb.novaordis.com. The backup file is named similar to 2023.12.30-03.00.01-not500-kb.novaordis.com-backup.tgz.

Check Preconditions

At this point, the new Media Wiki installation procedure should have created a transient database and database user, necessary for instance initialization and setup, as defined here Media Wiki Installation | Instance Restoration. At the end of the restoration, both the transient database and the database users will be deleted as described in Transient Database Cleanup. Verify that they are indeed created, and they are the only Media Wiki database and database user:

Connect to MariaDB
SHOW DATABASES;
SELECT user FROM mysql.user;

Restore the Database

Use the restoration script in --database-only mode. The script will request the local MariaDB database password root at stdin.

backup-system/mediawiki-restore --database-only /Users/ovidiu/tmp/2024.01.01-03.00.02-not500-kb.novaordis.com-backup.tgz /opt/brew/var/www/mediawiki-1.39.6

At this point, the MariaDB instance must contain both the temporary and the production database and database users.

SHOW DATABASES;
SELECT user FROM mysql.user;

(Optional) Update the Database

If the Media Wiki version of the instance we are using as source is older than the Media Wiki version we are restoring into, perform a database upgrade. From the target Media Wiki instance root directory:

cd /opt/brew/var/www/mediawiki-1.35.14
php maintenance/update.php

MediaWiki 1.35.14 Updater

Your composer.lock file is up to date with current dependencies!
Going to run database updates for novaordis_wiki
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds (skip this countdown with --quick) ... 0
...have ipb_id field in ipblocks table.1

...

el_id 10010 - 10402 of 10402
Done, 24 rows updated, 8 deleted.
Purging caches...done.
 
Done in 2 min 25 s.

Start httpd and Test

brew services start httpd

The new database content should be accessible.

Restore Images

Use the restoration script in --image-files-only mode. The script will restore the images directory content.

backup-system/mediawiki-restore --image-files-only /Users/ovidiu/tmp/2024.01.01-03.00.02-not500-kb.novaordis.com-backup.tgz /opt/brew/var/www/mediawiki-1.39.6

Work in Progress

mediawiki-restore has logic to restore keys and certificates, and compare the old and new installation to report the differences. Document that.

Post Restoration

Transient Database Cleanup

Drop the transient database and user:

DROP DATABASE tmp_mediawiki_db;
DROP USER 'tmp_mediawiki_user'@'localhost';
COMMIT;