LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 09-24-2010, 12:11 PM   #1
dazdaz
Member
 
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.

Code:
WIKI_USERNAME=WikiSysop
WIKI_PASSWORD=abcdefgh
TARGETHOST=http://www.myhost.org/wiki

# 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
alunduil
Member
 
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?

Regards,

Alunduil
 
Old 09-25-2010, 02:13 PM   #3
dazdaz
Member
 
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.

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

--19:53:03--  http://www.myhost.org/wiki/index.php?title=Special:Userlogin&action=submitlogin&type=login
Resolving www.myhost.org... 102.196.111.15
Caching www.myhost.org => 102.196.111.15
Connecting to www.myhost.org|102.196.111.15|: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: */*
Host: www.myhost.org
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 www.myhost.org
X-Cache-Lookup: MISS from www.myhost.org:80
Via: 1.0 www.myhost.org:80 (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 www.myhost.org -1 (ANY) / <session> <insecure> [expiry none] wikidb_mw_bd_session ak501c3bcjssuh5fbnsae245v8
TEXTHTML is on.
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
choogendyk
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 -- http://dev.mysql.com/doc/refman/5.1/...p-methods.html -- 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
dazdaz
Member
 
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.

http://labs.creativecommons.org/2011...-to-mediawiki/

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....

Code:
#!/bin/bash

PAGE_TITLE="Pad_Thai"

RCPT_TO="carl@gmail.com"
MAIL_FROM="'John Q. Public' <management@somesite.com>"
MAIL_SUBJECT="Contents of ${PAGE_TITLE}"

MW_LOGIN="carl"
MW_PASSWD="XXXXXX"

URL="https://www.chiangmai.com/wiki/index.php"

# 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}" \
        "${URL}?title=Special:UserLogin&action=submitlogin&type=login"

wget -q -O email_body.txt --no-check-certificate --load-cookies cookies.txt \
        "${URL}/${PAGE_TITLE}?action=raw"

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

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


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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