pages tagged mediawiki http://meng6net.localhost/tag/mediawiki/ <p><small>Copyright © 2005-2020 by <code>Meng Lu &lt;lumeng3@gmail.com&gt;</code></small></p> Meng Lu's home page ikiwiki Tue, 16 May 2017 23:59:39 +0000 Backup MediaWiki http://meng6net.localhost/computing/sysadmin/backup_mediawiki/ http://meng6net.localhost/computing/sysadmin/backup_mediawiki/ backup mediawiki note sysadmin Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <p>Here is a memo on backing up MediaWiki instances, say deployed as a part of a Web site <code>mywebsite.com</code>.</p> <p>Here is a listing of concrete steps:</p> <p>Get inside the backup root directory on local file system:</p> <pre><code>cd /Volumes/BACKUP/mywebsite.com </code></pre> <h2>Backup using the <code>backup_mediawiki.sh</code> backup script</h2> <ol> <li>Login web server</li> <li>Update VCS repository <code>https://github.com/lumeng/MediaWiki_Backup</code></li> <li>Back up using <code>MediaWiki_Backup/backup_mediawiki.sh</code> <pre> # assuming web directory is ~/mywebsite.com/wiki WIKI_PATH="mywebsite.com/wiki" # assuming the path to save a subdirectory backup_YYYYMMDD created by backup is path/to/backup/mywebsite.com/wiki WIKI_BACKUP_PATH="path/to/backup/mywebsite.com/wiki" # get to the home path before start cd # Start backup. This will create backup path/to/backup/mywebsite.com/wiki/backup_YYYYMMDD. path/to/backup_mediawiki.sh -d $WIKI_BACKUP_PATH -w $WIKI_PATH </pre></li> <li>Rsync the backup to a local hard drive: <pre> cd /Volumes/BACKUP/mywebsite.com </pre> <h1>Backup the whole web site user's home directory that includes the backup files created above, using rsync</h1> <pre> <br />rsync --exclude-from rsync_backup_exclusion.txt -thrivpbl user@webhost.com:/home/websiteuser rsync_backup/ </pre></li> <li>Ideally, upload the backup to cloud storage such as Drobpox.</li> </ol> <h2>HTML backup using <code>wget</code> for immediate read</h2> <p>Optionally, one can also keep a crawled version of a MediaWiki instances. Sometimes, it can be useful to have a copy of HTML files for immediate read offline.</p> <pre><code>cd /Volumes/BACKUP/mywebsite.com/wget_backup mkdir mywebsite.com-wiki__wget_backup_YYYYMMDD cd mywebsite.com-wiki__wget_backup_YYYYMMDD # crawl the whole Web site # wget -k -p -r -E http://www.mywebsite.com/ # crawl the pages of the MediaWiki instance excluding the Help and Special pages wget -k -p -r --user-agent='Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36' -R '*Special*' -R '*Help*' -E http://www.mywebsite.com/wiki/ cd .. 7z -a -mx=9 mywebsite.com-wiki__wget_backup_YYYYMMDD.7z wget_backup_YYYYMMDD </code></pre> <p>Remarks:</p> <ul> <li><code>-k</code>: convert links to suit local viewing</li> <li><code>-p</code>: download page requisites/dependencies</li> <li><code>-r</code>: download recursively</li> <li><code>--user-agent</code>: set "fake" user agent for the purpose of emulating regular browsing as sometimes site checks user agent. Check user agent string at <a href= "http://www.useragentstring.com/pages/Chrome/">useragentstring.com</a>.</li> </ul> <p>As for time cost to create the wget-crawled backup, for reference, it took about 30 min to download a small MediaWiki installation with hundreds of user-created pages in an experiment I did.</p> <p>If there is a small set of pages that you need to backup, <code>curl</code> may be alternatively used, for example,</p> <pre><code># download multiple pages curl -O http://mywebsite.com/wiki/Foo_Bar[01-10] </code></pre> <h2>References</h2> <ul> <li>https://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki</li> <li>https://www.mediawiki.org/wiki/Fullsitebackup</li> <li>https://www.mediawiki.org/wiki/Manual:DumpBackup.php</li> <li>https://wikitech.wikimedia.org/wiki/Category:Dumps</li> </ul> Back up MediaWiki http://meng6net.localhost/blog/backup_mediawiki/ http://meng6net.localhost/blog/backup_mediawiki/ blog computing mediawiki sysadmin Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <p>Wrote a <a href= "http://meng6.net/pages/computing/sysadmin/backup_mediawiki/">note</a> about backing up MediaWiki including its database (MySQL or SQLite), content pages exported as an XML file, all images, and the entire directory where MediaWiki installed, which includes <code>LocalSettings.php</code> and extensions that usually contain customization.</p> /blog/backup_mediawiki/#comments