码迷,mamicode.com
首页 > 其他好文 > 详细

backup Mediawiki

时间:2019-07-07 09:40:45      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:running   pac   something   dia   creat   ping   completed   database   fir   

Problem

How to move mediawiki from ubuntu to wsl?

Solution

Notation

  • [wikifolder]: where your wiki locate
  • [wikidb]: database wiki uses
  • [wikidb_user]: user of database
    Assuming we have two servers:
  • Server 1
    [wikifolder]: /var/www/html
    [wikidb]: wikidb
    [wikidb_user]: root
  • Server 2
    [wikifolder]: /var/www/html
    [wikidb]: wikidb
    [wikidb_user]: wikiuser

Old mediawiki is in Server 1. We‘d like to back up it, then scp to Server 2, finally restore from it in Server 2.

backup database in Service 1

  • First insert the following line into LocalSettings.php
$wgReadOnly = 'Dumping Database, Access will be restored shortly';

this can be removed as soon as the dump is completed.

mysqldump --default-character-set=binary -u root -p -h localhost --opt wikidb > wikidb-backup.sql

For more, See Mysqldump_from_the_command_line, and Back up in schedule

backup website in Service 1
tar czpvf mediawiki-1.23.13-backup.tar.gz /var/www/html

Restore in Service 2

Import the database backup

On the server on which you are restoring MediaWiki, ensure you have

  • a correctly-working instance of MySQL
  • a MySQL user with appropriate permissions, if you can‘t use MySQL user root
mkdir mediawiki_backup && cd mediawiki_backup/
cp /mnt/c/Users/chencanyi/Videos/wikidb-backup.sql ~/mediawiki_backup/ # or you can use scp
  • If a database exists and you want to entirely replace it from the backup. To destroy the database:
mysqladmin -u wikiuser -p drop wikidb
  • Then to create a new database and restore from backup:
mysqladmin -u wikiuser -p create wikidb
mysql -u wikiuser -p wikidb < wikidb-backup.sql
php /var/www/html/maintenance/update.php

Import the MediaWiki files

Assuming you are in Service 1.

scp ubuntu@Service1:~/mediawiki_backup/mediawiki-1.23.13-backup.tar.gz ~/mediawiki_backup/
cd ~/mediawiki_backup/
tar -xvzf mediawiki-1.23.13-backup.tar.gz
rm -fR [wikifolder]/
mv ./var/www/html [wikifolder]
  • Restart apache2 & mysql
sudo service apache2 restart
sudo service mysql restart

Check the configuration file

  • IP

Something more

  • where to find database configure?
cd /var/www/html
vi LocalSettings.php
# Something like 
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "wikidb";
$wgDBuser = "root";
$wgDBpassword = "***";

References

  1. https://m.mediawiki.org/wiki/Special:MyLanguage/Manual:Moving_a_wiki
  2. https://blog.lilydjwg.me/2011/5/28/story-of-migrating-mediawiki.27048.html
  3. Manual:Restoring a wiki from backup
  4. Manual:Backing up a wiki
  5. https://blog.csdn.net/setoy/article/details/6562287

backup Mediawiki

标签:running   pac   something   dia   creat   ping   completed   database   fir   

原文地址:https://www.cnblogs.com/canyichen/p/11144926.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!