Backing Up Your DXP Cloud Environments

Just In Case

I had thought that I would stop with 4 parts to my series of posts about DXP Cloud, but it was recently requested that I talk about backing up DXP Cloud environments. I will start with a caveat: the process to backup DXP Cloud's UAT and DEV environments are not supported. It is on the DXPC team's roadmap, but not currently available. This process was originally tested and documented for my fellow Sales Engineers to backup and restore their demos on DXP Cloud, but lately, there have been requests from other groups for this information, and if there have been requests for this information internally, then there must be some desire for this externally, so here we are.

These steps were run from the DXP Cloud Admin Console shell in the Liferay service, but could also be run from the DXP Cloud CLI.

Requirements

  • Knowledge of how to navigate DXP Cloud
  • Knowledge of MySQL commands
  • Knowledge of Linux admin commands
  • wget utility (optional)

For DEV or UAT Environments

The steps here are only for use in DEV or UAT, as PRD has its own backup mechanism.

Archiving the Document Store

  1. Go to DEV/UAT
  2. Go to Services -> Liferay -> Shell
    1. It should put you in /opt/liferay
  3. Go into the data directory
    1. cd data
  4. Tar the document_library directory
    1. tar -zcf ${FILENAME_VOLUME}.tgz document_library
      1. Output can be any file format, like *.tar.gz, but *.tgz makes it easier to put back later.

Archiving the Database Schema

  1. Go to DEV/UAT

  2. Go to Services -> Liferay -> Environment Variables

  3. Go to Services -> Liferay -> Shell

    1. It should put you in /opt/liferay

  4. Create a dump of the database schema. 

    1. mysqldump -u$LCP_SECRET_DATABASE_USER -p$LCP_SECRET_DATABASE_PASSWORD $LCP_SECRET_DATABASE_NAME --databases --add-drop-database $LCP_SECRET_DATABASE_NAME| gzip -c | cat > $LCP_SECRET_DATABASE_NAME.gz

      1. You DO NOT need to find these values. These environment variables are available in the shell and you can invoke them as the above command has done.

      2. You can copy the above command verbatim!

      3. This will take the database that is currently being used for that instance. If you have additional database schemas, you will need to run the dump command separately and with the specific name.

  5. Tar the output *.gz file

    1. tar -zcf $LCP_SECRET_DATABASE_PASSWORD.tgz $LCP_SECRET_DATABASE_PASSWORD.gz

 

Make the Files Available For Access

This process is not endorsed or supported by DXP Cloud and was deemed “hacky but with a smiley face.” It works, but there may be other methods out there.

  1. Go to DEV/UAT

  2. Go to Services -> Liferay -> Shell

    1. It should put you in /opt/liferay

  3. Copy the files into Tomcat for service

    1. Create a new directory called “backup” in ${TOMCAT}/webapps

      1. mkdir ${TOMCAT}/webapps/backup

    2. Copy the archive files into that directory

      1. cp ${FILENAME_VOLUME}.tgz ${TOMCAT}/webapps/backup

      2. cp ${FILENAME_DATABASE}.tgz ${TOMCAT}/webapps/backup

        1. Note, the file names are what were generated in the previous 2 steps.

Downloading the files

  1. Open a command prompt to where you want the files stored on your local machine.

  2. Use wget to download the files

    1. wget --no-check-certificate https://webserver-${REPOS_NAME}-${DEV/UAT}.lfr.cloud/backup/${FILENAME}

    2. If the web server pop-up authentication is still enabled, you will need to add in those flags

    3. wget --no-check-certificate --user=customer --ask-password ${URL}

      1. It will prompt for the password. Paste and hit Enter. It will not show characters.

      2. Refer to the DXP Cloud account welcome email for specific credentials.

Alternative Process for Making Files Available

This process was suggested by someone on the DXP Cloud team, but it was also deemed “hilariously hacky” so use at your own risk. Instead of using wget to download the files into the local file system, do the following.

  1. Go to DEV/UAT

  2. Go to Services -> Liferay -> Shell

    1. It should put you into /opt/liferay

  3. Use the same cURL commands to push the archive files from the lower environment up to PRD’s backup system

    1. curl -X POST https://backup-${REPO_NAME}-prd.lfr.cloud/backup/upload -H 'Content-Type: multipart/form-data' -F 'database=@${FILENAME_DATABASE}.tgz' -F 'volume=@${FILENAME_VOLUME}.tgz' -u email@address.com:password

      1. If you have special characters in your password, like ! it will need to be escaped with \, otherwise the bash shell will read the ! as the command to display the last entry in the shell.

        1. If your password is password123!! then you will need to put password123\!\!

        2. the -u email@address.com:password flag is the login email and password for DXP Cloud. If you are using SSO, you will need to provide the token instead.

  4. Download the backup files from the PRD Backups system.

WGET download vs DXP Cloud Backup?

First, let me start by saying neither is really more supported than the other. Both are equally unsupported methods. However, there are pro/cons to either one. You can still wget the DXP Cloud backups.

WGET pros

  • Simpler, less steps

WGET cons

  • Less secure. Files are available for all if they can find the URL, no protection if you have removed webserver auth.

  • Files are non-permanent and are removed if the service is restarted.

Cloud Backup pros

  • Persistent backup files

  • Tied into DXP Cloud’s backup infrastructure

Cloud Backup cons

  • Lots of shell manipulation

  • Extra steps, more complex

The final answer on which one to use is completely up to you. While more complicated, I do lean slightly towards using the Cloud Backup mechanism because it does keep a record of the backup for use and the backup can be directly restored using DXP Cloud's restore mechanism.

For PRD Environment

As mentioned previously, PRD has its own backup mechanisms, so we don't have to do cURL commands or take manual database dumps. This process IS supported though!

  1. Go to PRD

  2. Go to Backups

  3. To take a manual backup, press “Backup Now”

  1. Download the backup files using the 3-dot menu

Restoring the Backup to DXP Cloud

I'm not going to cover restoring the backup, because the whole process is outlined in Part 3.

All Prior Entries in this series

Dockerizing a Liferay Bundle Part 1
Dockerizing a Liferay Bundle Part 2
Migrating a Liferay Bundle to DXP Cloud
Local Work with DXP Cloud