Using Cloud DB Backups in your Local Development Environment

Often I’ve found when testing locally I couldn’t recreate a bug from a Test environment, or access functionality because I didn’t have the proper data. In some cases, it would be much quicker to simply take the data from my test environment and use it on my local machine. Here is a step by step guide on how to get data from your Mendix Cloud testing environments restored on your machine for testing.

Start by downloading and installing pgAdminIII (download). During the installation you will create a username and password which you’ll need later on in this tutorial.

To download the database backup, go to the deploy section of your project dashboard and go to the Backup tab:

image1

You can now choose to create a new backup or select an existing one. A full backup is typically what I download, but just the DB can be useful as well.

image2

The downloaded files have the tar.gz extension. When you extract the files, you can find the db.backup file in the ‘db’ folder:

image3

This is the file you will use. If you then open pgAdmin you will see this view:

image4

Right-click the PostgreSQL server and ‘Connect’, you should get this:

image5

You will have 0 Databases. Right click on Databases and select ‘New Database…’

image6

Create the new DB, setting the Owner to the user you created earlier (mine is named postgres):

image7

Once that is created, right click on NewDatabase and select ‘Restore’.

image8

In the popup, select the db.backup file we downloaded earlier, and select ‘Restore’:

image9

It will take approximately 30 seconds, and then you will see something similar to this:

image10

You can then hit ‘Cancel’. Then we must update our modeler to point to the new DB. Open the project settings and create a new configuration:

image11

In the new configuration, set the type to PostgreSQL, the URL to localhost, change the Database name to whatever you set (in my example, NewDatabase) and use the username and password that was set during the installation of pgAdmin as the owner of the DB. The name of the configuration can be whatever you want – it will be committed to the Team Server, so I would suggest including your name in it so you can easily identify yours:

image12

Make sure this is the active configuration, and start your application:

image13

You will now have a local test DB!

Please be aware these backups include the usernames and passwords from those environments (except for MxAdmin). You will want to update the passwords of users so you can sign in as a specific other user.