Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-24-2010, 12:11 PM   #1
Registered: Aug 2003
Location: Europe
Distribution: RHEL, CentOS, Ubuntu
Posts: 333

Rep: Reputation: 17
Backing up MediaWiki 1.16.0

I had a script, see below, which used to work to make a html backup my mediawiki. I just upgraded to 1.16.0 and now it's broke as it won't authenticate, this part must of changed.

Of course I also use mysqldump, but I also like to make a html snapshot of the wiki.

Does anyone know how it's changed to allow authentication once more.


# Save cookie
wget --save-cookies cookies.txt --post-data 'wpName='$WIKI_USERNAME'&wpPassword='$WIKI_PASSWORD'&wpRemember=1&wpLoginattempt=Log%20in' ${TARGETHOST}/index.php\?title=Special:Userlogin\&action=submitlogin\&type=login

# Load cookie
wget --mirror --no-parent --page-requisites --convert-links --no-host-directories --html-extension --cut-dirs=2 --load-cookies cookies.txt --directory-prefix=. ${TARGETHOST}/index.php/Main_Page -P /var/backup-web/html/

Last edited by dazdaz; 09-25-2010 at 04:16 PM.
Old 09-24-2010, 02:44 PM   #2
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
Is it possible for you to provide the error you get while running this script as well?


Old 09-25-2010, 02:13 PM   #3
Registered: Aug 2003
Location: Europe
Distribution: RHEL, CentOS, Ubuntu
Posts: 333

Original Poster
Rep: Reputation: 17
I made a typo in the script above which has been corrected.

It's not saving the cookie into the cookies.txt which makes me wonder if the authentication URL has changed with 1.16.0

Here is the first wget with debug (-d). Certain values have been changed for obvious reasons.

DEBUG output created by Wget 1.10.2 (Red Hat modified) on linux-gnu.

Caching =>
Connecting to||:80... connected.
Created socket 4.
Releasing 0x0808c1b0 (new refcount 1).

---request begin---
POST /wiki/index.php?title=Special:Userlogin&action=submitlogin&type=login HTTP/1.0
User-Agent: Wget/1.10.2 (Red Hat modified)
Accept: */*
Connection: Keep-Alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 73

---request end---
[POST data: wpName=WikiSysop&wpPassword=abcdefgh&wpRemember=1&wpLoginattempt=Log%20in]
HTTP request sent, awaiting response...
---response begin---
HTTP/1.0 200 OK
Date: Sat, 25 Sep 2010 18:53:03 GMT
Server: Apache
X-Powered-By: PHP/5.x.x
Set-Cookie: wikidb_mw_bd_session=ak501c3bcjssuh5fbnsae245v8; path=/
Content-Language: en
Vary: Accept-Encoding,Cookie
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: private, must-revalidate, max-age=0
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from
X-Cache-Lookup: MISS from
Via: 1.0 (squid/2.x.STABLExx)
Connection: close

---response end---
200 OK
hs->local_file is: index.php?title=Special:Userlogin&action=submitlogin&type=login.3 (not existing)

Stored cookie -1 (ANY) / <session> <insecure> [expiry none] wikidb_mw_bd_session ak501c3bcjssuh5fbnsae245v8
Length: unspecified [text/html]
Saving to: `index.php?title=Special:Userlogin&action=submitlogin&type=login.3'

     0K ..........                                              262M=0s

Closed fd 4
19:53:03 (262 MB/s) - `index.php?title=Special:Userlogin&action=submitlogin&type=login.3' saved [10488]

Saving cookies to cookies.txt.
Done saving cookies.

# cat cookies.txt
# HTTP cookie file.
# Generated by Wget on 2010-09-25 19:53:03.
# Edit at your own risk.

Last edited by dazdaz; 09-25-2010 at 02:20 PM.
Old 09-26-2010, 07:44 PM   #4
Senior Member
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
This seems like kind of an indirect method of backing up your wiki. How would you picture the recovery process if you needed to use this backup?

Why not use mysqldump or mysqlhotcopy -- -- and then use gtar, rsync, rdiff-backup or something else to maintain a backup of your webtree and mysqldumps on another server or drive? Although it seems slightly more complex, recovery would be more straightforward.
Old 09-27-2010, 11:14 AM   #5
Registered: Aug 2003
Location: Europe
Distribution: RHEL, CentOS, Ubuntu
Posts: 333

Original Poster
Rep: Reputation: 17
For backup and recovery I use mysqldump. I realised that I had used the wrong wording above which may of misled (sorry)

Using wget in the past has allowed me to view the wiki offline, i.e. on my mobile I can carry the content and view it offline. For me that is extremely useful, especially if you have no data plan or no access to wifi.

You now have to use the wpLoginToken to authenticate via MediaWiki 1.16.0 so that you can download a MediaWiki page using wget inside of a script.

I've made some small modification's to the script on the URL above to make it easier to use. This is very handy script....



MAIL_FROM="'John Q. Public' <>"



# Mediawiki uses a login token, and we must have it for this to work.
WP_LOGIN_TOKEN=$(wget -q -O - --save-cookies cookies.txt --keep-session-cookies --no-check-certificate \
                                     ${URL}/Special:UserLogin \
                                     | grep wpLoginToken | grep -o '[a-z0-9]\{32\}')

wget -q --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies --no-check-certificate \
        --post-data "wpName=${MW_LOGIN}&wpPassword=${MW_PASSWD}\
&wpRemember=1&wpLoginattempt=Log%20in&wpLoginToken=${WP_LOGIN_TOKEN}" \

wget -q -O email_body.txt --no-check-certificate --load-cookies cookies.txt \

cat email_body.txt | mail -s "${MAIL_SUBJECT}" ${RCPT_TO}

Last edited by dazdaz; 05-15-2011 at 05:14 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mediawiki question Harry Seldon Linux - Server 2 10-19-2007 01:19 PM
[OpenBSD 4.0] Mediawiki in chroot noir911 *BSD 5 02-12-2007 12:58 PM
MediaWiki on Core 4 interOperate Fedora 1 08-23-2005 08:18 AM
mediawiki spellchecker jdd Linux - Software 2 08-04-2005 05:26 AM
mediawiki noir911 General 1 07-01-2005 07:18 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration