Restoring a Backup Locally

Last modified: January 24, 2024

1 Introduction

Restoring a backup locally can be useful if you want to test your cloud environment’s data without interrupting your live cloud environment. This lets you see locally how your app behaves when using data in your cloud environment. By using Mendix Studio Pro and a PostgreSQL database, you can debug your app using backups of your cloud test/acceptance/production data.

This how-to explains how to do the following:

  • Download a backup from your cloud environment
  • Create a new database
  • Configure the settings of the app
  • Download and restore FileDocument (binary) objects in your Domain Model

2 Prerequisites

Before starting this how-to, make sure you have completed the following prerequisites:

  • Download a backup that you want to restore locally.

  • Install PostgreSQL version 12 or above (as you need pgAdmin version 4.12 or above) on your local machine by downloading and running the PostgreSQL Installer. When installing, use the program defaults and choose a password.

  • When you are restoring a database hosted in Mendix Cloud, or when downloading a full backup, your local machine must have 7zip or another utility that can extract files from .gz and .tar archives.

3 Restoring the Backup to Postgres

Once PostgreSQL is installed and you have downloaded a backup file, you need to create a local database in PostgreSQL. The backup database will be restored into this local PostgreSQL database.

  1. Start pgAdmin 4 from the Windows start menu.

  2. Click the + in the Browser pane to open the Servers > PostgreSQL 9.6 menu.

  3. Right-click Databases and Create a new database.

  4. Fill in the Database name.

  5. Select the correct owner (the default is postgres) and click Save.

  6. Right-click the newly created database and click Restore.

  7. Select the .backup file you downloaded from the Team Server.

  8. Click the Restore options tab.

  9. Under Do not save, set Owner to Yes.

  10. Click Restore.

  11. Wait until you see a message that the backup is “Successfully completed.” This message appears in the right corner of the screen.

4 Linking the Database to the App in Mendix Studio Pro

After the backup has been restored as a local Postgres database, you have to link the database to Studio Pro. This tells Studio Pro to use the database that you have just created in PostgreSQL, rather than the database that was originally created with the app.

  1. Open your app in Studio Pro.

  2. Open App > Settings from the App Explorer.

  3. Under the tab Configurations, click New.

  4. Fill in the database information:

    • Name: {a unique name}
    • Type: PostgreSQL
    • URL: localhost:5432
    • Database name: {database name} (the name of the database you created in pgAdmin)
    • User name: {database owner} (set when you created the database in pgAdmin; the default is postgres)
    • Password: {password for database owner} (by default, this is the password you provided for Postgres when first setting up PostgreSQL)
  5. Click OK.

  6. Run the app by clicking Run Locally ( ) or choosing the menu option Run > Run Locally.

5 Restoring Files

The steps above restore the database but do not restore any FileDocuments (which are binary files, such as images).

If you also want to restore the FileDocuments, follow these steps:

  1. Download a Full Snapshot.

  2. Select App > Show App Directory in Explorer from the Studio Pro menu:

  3. Navigate to the deployment/data/files folder within your app.

  4. Extract the {backup name}.tar file from the .gz archive using a program like 7-zip.

  5. Extract the contents of your tree folder from the backup archive to the deployment/data/files folder within your app.

  6. Run the app by clicking Run Locally ( ) or choosing the menu option Run > Run Locally.

6 Read More