HowCanIUpdateXWIKIFromAnOlderVersion

Last modified by Jeroen Baten on 2010/09/15

Question How can I upgrade XWIKI from an older Version?
Answer Answer on myself experience.

1/ re-deploy war (easy part)
By chance we didn't update any files excepted xwiki.cfg and hibernate.cfg.xml.
So I did the following:

  • zip current webapp/xwiki folder
  • remove webapp/xwiki folder
  • deploy xwiki-enterprise-web-2.0.5.war in webapp/xwiki
  • report my old xwiki.cfg and hibernate.cfg.xml configuration to the new one
2/ import xar (difficulties start here)
First, I import the full xar without any question: whao, everything is broken.
Do not forget to backup your database before upgrade!
After restoration, I decide to write a small script based on curl to export same xar as the one I want to import:
#!/bin/bash
XWIKI_BASE_URL=http://localhost:8080
if [[ $# -ne 2 ]]; then
   echo usage $0 login password
   exit 1
fi
EXPORT_XAR="?format=xar&name=Current"
for page in `jar tvf xwiki-enterprise-wiki-2.0.5.xar | sed -ne "/\/.*xml/{s/.*\s\(\S\+\)\/\(\S\+\).xml/\1.\2/ p}"`; do
   EXPORT_XAR="${EXPORT_XAR}&pages=${page}"
done
curl -b cookies.txt -c cookies.txt -d"j_username=$1&j_password=$2&j_rememberme=true&submit=Log-in" ${XWIKI_BASE_URL}/xwiki/bin/loginsubmit/XWiki/XWikiLogin
curl -b cookies.txt -c cookies.txt ${XWIKI_BASE_URL}/xwiki/bin/export/Main/WebHome${EXPORT_XAR} -o Current.xar
Whatever I used the best diff tool (Beyond Compare IMHO), it is not so easy to check if difference are good or not: I need other way.
Thanks to RESTful API, I write a second script which check page version: version 1.1 was never updated from previous xar version:
#!/bin/bash
XWIKI_BASE_URL=http://localhost:8080
for page in `jar tvf xwiki-enterprise-wiki-2.0.5.xar | sed -ne "/\/.*xml/{s/.*\s\(\S\+\)\/\(\S\+\).xml/\1\/pages\/\2/ p}"`; do
   version=`curl -s -b cookies.txt -c cookies.txt ${XWIKI_BASE_URL}/xwiki/rest/wikis/xwiki/spaces/$page | sed -ne "/version/{s/.*version>\(.*\)<\/version.*/\1/ p}"`
   if [[ $version != "1.1" ]]; then
       echo $page $version UPDATED
   fi
done

Warning: Remember to change port number according to your environment and *.xar filename (version number) in script files!

Cool, only 8 updated pages:

Main/pages/WebHome 144.1 UPDATED
XWiki/pages/XWikiUserSheet 4.1 UPDATED
XWiki/pages/XWikiAdminGroup 4.2 UPDATED
XWiki/pages/XWikiPreferences 78.1 UPDATED
XWiki/pages/LiveTableResults 2.1 UPDATED
XWiki/pages/XWikiAllGroup 34.1 UPDATED
XWiki/pages/WebPreferences 3.2 UPDATED
XWiki/pages/LiveTableResultsMacros 2.1 UPDATED
All other pages can be updated without any check :-D
  • Main.WebHome: it is our own main page
  • XWiki.AdminGroup and XWikiAllGroup: list Admin users and users
  • XWiki.XWikiUserSheet, we apply a patch to display user contribution: not updated
  • XWiki.LiveTableResults and XWiki.LiveTableResultsMacros, I check with my diff tool: there is a tag object inside.should not updated it.
  • XWiki.WebPreference and XWiki.XWikiPreferences contain our preferences
Tags:
Created by mauermbq on 2006/10/09
    

Get Connected