Documentation

Using the Database Upgrade Tool

The Liferay Database Upgrade Tool is a client program for upgrading Liferay DXP and Liferay Portal databases offline.

Important

Always back up your data and installation before upgrading. Testing the upgrade process on backup copies is advised.

Important

If you’re upgrading from 6.2 or earlier, update your file store configuration. See the Updating the File Store for more information.

Modifying a database while it’s detached from your Liferay instance allows you to tune the database for upgrade operations, prune unnecessary data (e.g., unneeded versions of Web Content, Documents, and more) to improve upgrade performance, and resolve upgrade issues. These activities are especially important for upgrading DXP and any large, critical Portal environments safely and as quickly as possible. After you’ve accounted for tuning and pruning the database and completing relevant tasks described in Upgrade Basics, you’re ready to setup up the new installation and upgrade the database using the upgrade tool.

If you’re upgrading to a new Liferay Docker image and want to use the upgrade tool, use it from a Liferay Tomcat Bundle of the new Liferay version. The tool is in the bundle’s tools/portal-tools-db-upgrade-client folder.

If you installed the new Liferay release on an application server, create a [Liferay Home]/tools/portal-tools-db-upgrade-client folder, download the upgrade tool, and install the tool to the new folder.

Edition

Download Instructions

Liferay DXP (Subscription)

Go to the Downloads page and select the DXP version and the Product/Service Packs file type. In the listing that appears, click Download for the Liferay DXP Upgrade Client.

Liferay Portal

Go to the Downloads page. In the Liferay Portal downloads menu, select Other files and click Download. The latest Liferay Portal release assets GitHub page appears. Click on liferay-ce-portal-tools-[version].zip.

Setting Up a New Installation

  1. Replace the new Liferay installation’s [Liferay Home]/data folder with the [Liferay Home]/data folder from your backup.

  2. Copy your DXP activation key (Subscription) and your OSGi configuration files from your backup to the new installation.

  3. If you’re upgrading to 7.2, disable search indexing using a configuration file in your new installation’s [Liferay Home]/files/osgi/configs/ folder. For example,

    cd liferay-home
    
    mkdir -p osgi/configs
    
    echo "indexReadOnly=\"true\"" >> osgi/configs/com.liferay.portal.search.configuration.IndexStatusManagerConfiguration.config
    

    Note

    DXP/Portal 7.3+ disables/re-enables search indexing automatically.

  4. If you’re using Commerce, prepare to upgrade it. See Upgrading Liferay Commerce for details.

  5. If you want to upgrade your Marketplace app data along with the Liferay database upgrade, download the latest version of each app targeted for the new Liferay version and copy it to your [Liferay Home]/deploy folder. Otherwise, you can install the apps after the database upgrade and upgrade their data as described in the Post-Upgrade Considerations.

  6. If you’re using Advanced File System Store or Simple File System Store with a modified storage location, export your file store settings to a .config file and copy it to your new [Liferay Home]/osgi/configs/ folder.

    Important

    If you’re using Advanced File System Store, you must configure it with a .config file in the new installation before upgrading the database.

    Here’s an example com.liferay.portal.store.file.system.configuration.AdvancedFileSystemStoreConfiguration.config file with the required rootDir parameter:

    rootDir="data/document_library"

  7. Use your database vendor’s recommended JDBC database driver. If you’re using MySQL, for example, set jdbc.default.driverClassName=com.mysql.cj.jdbc.Driver in your portal-ext.properties file and replace the MySQL JDBC driver JAR your app server uses. See Database Drivers for more details.

    You can configure the upgrade by answering the upgrade tool prompts or by using upgrade properties files.

    Note

    If you’re upgrading to a new Liferay Docker image, make sure to specify your database connection using Portal Properties files instead of Docker env variables. The Portal Properties reference lists Portal Properties that correspond with each Liferay Env variable.

  8. Optionally, enable upgrade reporting to log the environment, changes, and more to a report.

    echo "upgrade.report.enabled=\"true\"" << tools/portal-tools-db-upgrade-client/portal-upgrade-ext.properties
    

Running the Upgrade Tool

The upgrade tool is configured via its command line interface, or by using properties files.

The db_upgrade.sh script in the [Liferay Home]/tools/portal-tools-db-upgrade-client folder invokes the upgrade tool. The --help option describes the tool’s usage.

./db_upgrade.sh --help

Here’s how to upgrade your database with the upgrade tool:

  1. Start the upgrade tool. Here’s an example command:

    cd liferay-home/tools/portal-tools-db-upgrade-client
    
    ./db_upgrade.sh -j "-Dfile.encoding=UTF-8 -Duser.timezone=GMT -Xmx4096m"
    

    The command above executes the upgrade tool with the same JVM options recommended for the application server. File encoding (UTF-8), time zone (GMT), country, language, and memory settings (-Xmx value) should all match your application server’s settings. For databases with over 10 GB of data, allocate additional memory using the -Xmx option.

    If you haven’t configured the upgrade using the upgrade properties files, the upgrade tool prompts you for configuration values and shows default values in parentheses. Here’s an example interaction:

    Please enter your application server (tomcat):
    tomcat
    
    Please enter your application server directory (../../tomcat-9.0.17):
    
    Please enter your extra library directories (../../tomcat-9.0.17/bin):
    
    Please enter your global library directory (../../tomcat-9.0.17/lib):
    
    Please enter your portal directory (../../tomcat-9.0.17/webapps/ROOT):
    
    [ db2 mariadb mysql oracle postgresql sqlserver sybase ]
    Please enter your database (mysql):
    mariadb
    
    Please enter your database host (localhost):
    
    (etc.)
    

    If you want to use the default value shown in a prompt, press enter.

    After configuration completes, the upgrade starts. The tool logs each upgrade process start and completion.

  2. After the upgrade completes, check the upgrade report for any database upgrade failures, errors, or warnings. You can use Gogo Shell commands to troubleshoot issues and finish the upgrade.

You have completed the database upgrade and resolved any issues.

Test the Upgraded Database

Now that the database upgrade is complete, test it.

  1. If you’re upgrading to a new Liferay Docker image, point your image to the upgraded database and validate Liferay with the database. Please see Configuring Liferay Containers for more information.

  2. Examine the Post-Upgrade Considerations.

  3. Copy and merge your custom Liferay Home files and application server files from your backup to the new installation. The files may include but are not limited to these:

    • /license/*: Activation keys. (Subscription)

    • /log/*: Log files.

    • /osgi/configs/*.config: OSGi configuration files.

    • portal-*.properties: Portal properties files, such as portal-ext.properties.

    • Application server files: Modified scripts and configuration files.

    • web.xml: Portal web application descriptor.

  4. Update the Portal properties in your new installation.

  5. Start your server and validate Liferay with its upgraded database.

    Here is the Liferay DXP landing screen.

You’ve upgraded your Liferay database using the Database Upgrade Tool.

If this was a trial upgrade and you want to shorten the upgrade time, tune your database for upgrade (if you haven’t already) and remove unnecessary data from the database. Repeat this article’s steps as necessary.

If you run into issues, check the upgrade report and see Troubleshooting Upgrades.

Next Steps

Revisit Upgrade Basics to see what’s left to upgrade.