Upgrading

Last modified by Vincent Massol on 2017/11/21

Upgrading the standard distribution

If you've installed the standard distribution (exe, zip or jar distribution) and you wish to upgrade it, the simplest is to download the new version and install it as you did the first time. Just make sure you don't install the new version over the old one (both installations need to exist).

Then copy the configuration files and the permanent directory from the old installation to the new one (Best is to not copy the solr/ subdirectory since the SOLR schema could have changed and it's best to let XWiki reindex using the new schema). Ideally you should not copy over the configuration files exactly since the new version could have added new configuration options and thus ideally you should do a merge instead of a pure copy. Another strategy is to use the new configuration files, not copy over the old configuration files and instead manually edit the new configuration to make the same changes as you have may done before (If you've never touched the configuration files then there's nothing to do obviously!).

If you're on a unix system here are some commands that may help you doing the merge instead of doing it fully manually:

## Note: We're assuming that "xwiki.new" is a symbolic likns that points to the location
## where the new xwiki version is located and that "xwiki" is the location of the previous
## xwiki installation.
mv xwiki.new/WEB-INF/web.xml xwiki.new/WEB-INF/web.xml.ori; sudo sdiff xwiki/WEB-INF/web.xml xwiki.new/WEB-INF/web.xml.ori -B -W -E -o xwiki.new/WEB-INF/web.xml
mv xwiki.new/WEB-INF/xwiki.cfg xwiki.new/WEB-INF/xwiki.cfg.ori; sudo sdiff xwiki/WEB-INF/xwiki.cfg xwiki.new/WEB-INF/xwiki.cfg.ori -B -W -E -o xwiki.new/WEB-INF/xwiki.cfg
mv xwiki.new/WEB-INF/xwiki.properties xwiki.new/WEB-INF/xwiki.properties.ori; sudo sdiff xwiki/WEB-INF/xwiki.properties xwiki.new/WEB-INF/xwiki.properties.ori -B -W -E -o xwiki.new/WEB-INF/xwiki.properties
mv xwiki.new/WEB-INF/struts-config.xml xwiki.new/WEB-INF/struts-config.xml.ori; sudo sdiff xwiki/WEB-INF/struts-config.xml xwiki.new/WEB-INF/struts-config.xml.ori -B -W -E -o xwiki.new/WEB-INF/struts-config.xml
mv xwiki.new/WEB-INF/classes/logback.xml xwiki.new/WEB-INF/classes/logback.xml.ori; sudo sdiff xwiki/WEB-INF/classes/logback.xml xwiki.new/WEB-INF/classes/logback.xml.ori -B -W -E -o xwiki.new/WEB-INF/classes/logback.xml

Note that the database schema is automatically upgraded when needed. All you need to do is to ensure your xwiki.cfg file is correctly configured to perform the migration. Here's a relevant excerpt from the xwiki.cfg file:

#-# Whether migrations are enabled or not. Should be enabled when upgrading, but for a better startup time it is better to
#-# disable them in production.
xwiki.store.migration=1

#-# Whether to exit after migration. Useful when a server should handle migrations for a large database, without going
#-# live afterwards.
# xwiki.store.migration.exitAfterEnd=0

#-# Indicate the list of databases to migrate.
#-# to upgrade all wikis database set xwiki.store.migration.databases=all
#-# to upgrade just some wikis databases set xwiki.store.migration.databases=xwiki,wiki1,wiki2
#-# Note: the main wiki is always migrated whatever the configuration.
# xwiki.store.migration.databases=
From a failed migration the database tables DATABASECHANGELOG and DATABASECHANGELOGLOCK may be left over.
Ensure that these tables are dropped before restarting a failed migration.

Upgrading from the Debian package

Update packages index

sudo apt-get update

Package upgrade

Usually you will do:

sudo apt-get upgrade

This will upgrade all packages, not just XWiki. If you want to avoid all the other packages and only update XWiki, you can use sudo apt-get install xwiki-tomcat8-mysql (change xwiki-tomcat8-mysql for the top level package you installed if you installed something else).

When upgrading from pre 9.5 version apt-get upgrade won't find anything because the package name changed (XWiki Enterprise does not exist anymore).

All you have to do in this case is install the xwiki-tomcat* package corresponding to the top level xwiki-enterprise-tomcat* one you installed previously. For example if you had xwiki-enterprise-tomcat8-mysql 9.4 you should do sudo apt-get install xwiki-tomcat8-mysql.

Pages upgrade

However after upgrading you still need to install the new UI; see Upgrading wiki documents below.

Upgrading the webapp

The general strategy is to download the new WAR distribution and to replace your current installed WAR with it. However make sure you don't copy on top since this could leave some old files around which would make XWiki fail (like if old JARs are lying around in WEB-INF/lib). In addition you would override some XWiki configuration files located in WEB-INF (xwiki.properties and xwiki.cfg to name just two).

Thus, before replacing your current WAR, make sure you back it up, including configuration and data files.

Also you need to ensure that you use the same XWiki Permanent directory (configured in WEB-INF/xwiki.properties using the environment.permanentDirectory property). Best is to not copy the solr/ subdirectory since the SOLR schema could have changed and it's best to let XWiki reindex using the new schema

Some additional operations may be required for upgrading and you must check the release notes for all the versions from the version you're upgrading from up to the new version you're installing. It's also possible that new features are available and that some configuration files need to be modified. If this is the case then it'll be specified in the release notes.

Note that the database schema is automatically upgraded when needed. All you need to do is to ensure your xwiki.cfg file is correctly configured to perform the migration. Here's a relevant excerpt from the xwiki.cfg file:

#-# Whether migrations are enabled or not. Should be enabled when upgrading, but for a better startup time it is better to
#-# disable them in production.
xwiki.store.migration=1

#-# Whether to exit after migration. Useful when a server should handle migrations for a large database, without going
#-# live afterwards.
# xwiki.store.migration.exitAfterEnd=0

#-# Indicate the list of databases to migrate.
#-# to upgrade all wikis database set xwiki.store.migration.databases=all
#-# to upgrade just some wikis databases set xwiki.store.migration.databases=xwiki,wiki1,wiki2
#-# Note: the main wiki is always migrated whatever the configuration.
# xwiki.store.migration.databases=
From a failed migration the database tables DATABASECHANGELOG and DATABASECHANGELOGLOCK may be left over.
Ensure that these tables are dropped before restarting a failed migration.

Invalid Extensions

Also note that when you upgrade, some extensions that were previously valid may become invalid  (for example they may have been renamed, removed or have versions that do not match the version of the WAR you've installed as is the case with the example below). In this case you'll see in the console messages such as:

2013-12-02 11:43:01,688 [localhost-startStop-1] WARN  ltInstalledExtensionRepository - Invalid extension [org.xwiki.enterprise:xwiki-enterprise-ui-common-5.2.1] on namespace [wiki:xwiki]
2013-12-02 11:43:01,688 [localhost-startStop-1] WARN  ltInstalledExtensionRepository - Invalid extension [org.xwiki.platform:xwiki-platform-workspace-ui-5.2.1] on namespace [wiki:xwiki]
2013-12-02 11:43:01,688 [localhost-startStop-1] WARN  ltInstalledExtensionRepository - Invalid extension [org.xwiki.enterprise:xwiki-enterprise-ui-mainwiki-5.2.1] on namespace [wiki:xwiki]
2013-12-02 11:43:01,689 [localhost-startStop-1] WARN  ltInstalledExtensionRepository - Invalid extension [org.xwiki.enterprise:xwiki-enterprise-ui-wiki-all-5.2.1] on namespace [wiki:workspacetemplate] 

These are just warnings and don't affect that stability of your instance. Actually the Distribution Wizard you get (see the next section on "Upgrading wiki documents") will ask you to upgrade those invalid extensions and will remove the old versions that became invalid.

Upgrading from Docker

If you've installed XWiki by using the official XWiki Docker image, follow the instructions there for upgrading it.

Upgrading wiki documents

The recommended way to upgrade an XWiki installation is to use the Distribution Wizard which is automatically triggered after you upgrade the XWiki WAR. It allows you to automatically upgrade extensions installed in your wiki, supporting automatic merges and conflict resolution.

Make sure you run the Distribution Wizard (DW) with a user having Programming Rights. The following pages require being saved by a user having Programming Rights to work correctly and they may happen to have been modified and thus the DW may need to modify them:

  • AppWithinMinutes.DynamicMessageTool (kept for backward-compatibility, not used)
  • AnnotationCode.Style
  • AppWithinMinutes.LiveTableEditSheet
  • AppWithinMinutes.ClassEditSheet
  • Main.Activity
  • AnnotationCode.Script
  • XWiki.OfficeImporterAdmin
  • Filter.WebHome
  • XWiki.DeletedAttachments (Fixed in XWiki 9.8RC1)
  • XWiki.DeletedDocuments (Fixed in XWiki 9.8RC1)

If you have already done the upgrade with a user not having Programming Rights, then log in with a user having those permissions (or ask someone who has them), navigate to those pages, edit them (using the wiki editor preferably) and save them without any modification.

Prior to XWiki 4.3 you had to perform this manually as explained below.

Manual Upgrade

As mentioned in the Installing the Default Wiki XAR section you should be very careful and when doing the import make sure you selectively decide what pages you wish to import. More specifically the following pages should be imported with great care:

  • XWiki.XWikiPreferences: This page contains some configuration of your wiki (it overrides the configuration defined in xwiki.cfg). If you import a new version of this page you'll lose any customization you may have made such as the skin to use, the rights for your wiki, etc.
  • XWiki.WebPreferences, Main.WebPreferences, and all other spaces WebPreferences pages: Same as XWiki.XWikiPreferences but at the level of a space
  • XWiki.XWikiAllGroup (list of registered users) and XWiki.AdminGroup (list of Admins): If you have existing users and import a new version of these pages, you'll find that your users do not belong to these groups anymore and thus may not be able to edit pages, log in, etc. You'll need to add them again to the right groups
  • XWiki.Admin: This page contains the Admin user with the default password. If you import it you'll create a security hole. Thus it's very important not to import this page
  • *.*Config: These are configuration pages and thus must not be overwritten. Some examples:
    • XWiki.RegistrationConfig: Contains Registration configuration of your wiki
    • Invitation.InvitationConfig: Configuration for the Invitation Application
  • XWiki.XWikiServerXwiki (multi wiki): This page contains the server descriptors and wiki properties
  • Any other page you have modified, such as Main.WebHome, a modified Panel, etc.

Let's clean it up

  • Expand the XWiki WAR that you installed in your servlet container (the one that contains the JDBC drivers to access your database) into a new folder, using jar xvf xwiki-<suffix>.war or avoid this step if you performed an export/import data migration (you already expanded it)
  • Merge your old configuration files you have backed up (see above) with the new versions. Take care that if some changes were already made (probably because of database configuration when you installed the JDBC drivers) they could be lost, so take care when making these changes
  • Install this new folder as the xwiki application in your servlet container (by copying the folder to the servlet filesystem space or by packing it in a WAR file and deploying it in the container's administration interface)

At this point all is set and you can experience your old wiki data over the new XWiki core!

Alternative: Export and Reimport

There are cases when it's a better solution to export your current content as a XAR and reimport it into a new instance. For example this would be a good solution if you have a very old version of XWiki and wish to move to a new version.

This solution should work because the XWiki project takes great pride in being careful about backward compatibility and content created several years ago should still work well in new versions of XWiki. For example as of now, we still support XWiki Syntax 1.0 (even though it's been replaced by XWiki Syntax 2.0+ several years ago).

Some tips:

  • Make sure to only import your own content pages and not the default XWiki pages since you’d overwrite the ones provided in new XWiki install.
  • You may get issues when trying to export a large XAR. In that case you may want to try installing one of the Export Extensions but you'll need to verify that the one you install will work on your old version of XWiki.

Downgrading

You should try to upgrade to a version that fixes the issue you're facing instead of downgrading. However if you really need to downgrade, read on...

A previous upgrade may have modified the database schema and the data saved in the permanent directory may also have incompatible changes. Thus the best strategy for downgrading is to export your wiki pages as XAR (the ones having your content, not the default wiki pages provided by the XWiki distribution or installed Extensions). Then install the older XWiki version and re-install optional Extensions that you need. Then reimport your XAR in it.

Tags:
Created by Vincent Massol on 2017/09/06
   

Get Connected