Restore MX Cloud database into your local development environment
This assumes that you have a Mendix project downloaded in Mendix Studio Pro (Modeler) and that the same project is deployed to a Mendix Cloud node.
Via the UX
Note
The following program versions were used for this guide:
- PostgreSQL v12.1.3, Windows 64 bit
- DBeaver CE v6.3.0, Windows 32/64bit
- 7-Zip v19.00 Windows 64 bit
Download and install PostgreSQL
- Download the installer from https://www.enterprisedb.com/thank-you-downloading-postgresql?anid=1257093 (or check at https://www.postgresql.org/download/windows/ for the latest version).
- Run the installer as Administrator. If you get a UAC prompt, click “Yes”.
- When the setup wizard starts, click “Next >”.
- Leave the default installation directory alone (C:\Program Files\PostgreSQL\12) and click “Next >”.
- Uncheck everything except “PostgreSQL Server” and “Command Line Tools” then click “Next >”.
- Leave the default data directory alone (C:\Program Files\PostgreSQL\12\data) and click “Next >”.
- Enter “postgres” in both password boxes and click “Next >”.
- Leave the default port (5432) and click “Next >”.
- Leave the locale as “[Default locale]” and click “Next >”.
- Check the settings and click “Next >”.
- Click “Next >”.
- Wait for the installation to finish then click “Finish”.
Download and install DBeaver
- Download the installer from https://dbeaver.io/files/dbeaver-ce-latest-x86_64-setup.exe (or check at https://dbeaver.io/download/ for the latest version).
- Run the installer as Administrator. If you get a UAC prompt, click “Yes”.
- When the setup wizard starts, leave the language as “English” and click “Next >”.
- On the welcome screen, clickj “Next >”.
- Read the license if you want, then click “I Agree”.
- Leave “For anyone who uses this computer (all users)” selected and click “Next >”.
- Leave “DBeaver Community” checked and everything else unchecked and click “Next >”.
- Leave the installation directory alone (C:\Program Files\DBeaver) and click “Next >”.
- Leave the shortcut name as “DBeaver Community” and click “Install”.
- Wait for the installation to finish then click “Finish”.
Download and install 7-Zip
- Download the installer from https://www.7-zip.org/a/7z1900-x64.exe (or check at https://www.7-zip.org/download.html for the latest version).
- Run the installer as Administrator. If you get a UAC prompt, click “Yes”.
- Leave the default installation directory alone (C:\Program Files\7-Zip) and click “Install”.
- When the installation is complete, click “Close”.
Aquire a backup from the MX Cloud
- Browse to https://cloud.home.mendix.com/
- Click the “Details” button on the app you are working with
- From the left hand navigation, select “Backups”
- Use the select box to choose which environment to take the backup from
- Click the “Create backup” button
- When the backup has completed, select it and click the “Download backup” button
- Leave “Full snapshot” selected then click the “Start” button
- When the backup has been packaged, click the “Download” button
- Choose a location for the download and click “Save”
- Go to the download location, right-click the file and select 7-Zip > Extract here.
- When the extration has finished, right-click the resulting .tar file and select 7-Zip > Extract to {name of file}.
Copy uploaded files into the Mendix Deployment directory
- Open the directory that was created in the last step and then open the “tree” subdirectory.
- Select all files and folders in the directory, right-click and select “Copy” (or do Ctrl+A then Ctrl+C).
- Now open your Mendix Project directory, open the “deployment” subdirectory and then the “files” subdirectory.
- Now right-click and select “Paste” (or do Ctrl+V) to copy the backed up files into your project.
Create a new database and restore the backup using DBeaver
- Click the Start button then type “DBeaver” and click the resulting application to start DBeaver.
- The program should start with the “Connect to database dialog” open, but if not you can launch it from Database > New Database Connection.
- Select the “PostgreSQL” icon and click “Next >”.
- Make sure that the username and password are both “postgres” before clicking “Finish”.
- Download any drivers that are missing where prompted.
- In the “Database Navigator” panel on the left, right click the database server labeled “PostgreSQL - postgres” and select Create > Database.
- Give your new database a suitable app specific name and click “OK”.
- In the “Database Navigator” panel, right-click your new database and select Tools > Restore.
- When the Restore wizard has started, click the small folder icon to select the “Backup file” (it is in the directory you extracted under the db subdirectory).
- Enter “–no-owner” in the “Extra command args” box, then click “Start”.
- When the backup is complete, click “Cancel” to close the dialog (You may notice an error like “Process exit code: 1”. This is likely from the very start of the restore due the the scheme “public” already existing on the database. You can safely ignore it.).
- Close DBeaver.
Configure your project to use the new data
- Open your project in Mendix Studio Pro (Modeler).
- In the “Project Explorer” panel, expand the top level “Project” node and double-click “Settings” to open the Project Settings dialog.
- Under the “Configurations” tab, click the “New” button.
- In the New Configuration dialog:
- Give it a meaningful name;
- Change the “Type” to “PostgreSQL”;
- Change the “URL” to “localhost:5432”;
- Change the “Database name” to the one you chose in the previous section;
- Set the “User name” to “postgres” and set the “Password” to “postgres” as well.
- Click “OK”.
/.\
// \\
// o\\
//\/ \ \\
/=========\
WORK IN PROGRESS
Via the API in PowerShell
Via the API in bash (or similar shell)
username = ‘’ apikey = ‘’ appid = ‘’ environment = ‘test’
reply = curl –header “Content-Type: application/json”
–header “Mendix-Username: $username”
–header “Mendix-ApiKey: $apikey”
“https://deploy.mendix.com/api/1/apps/$appid/environments/$Environment/snapshots”
- Take a snapshot HTTP Method: POST URL: https://deploy.mendix.com/api/1/apps/{AppId}/environments/{Environment}/snapshots Headers: Content-Type: application/json Mendix-Username: {Your username} Mendix-ApiKey: {Your ApiKey}
Reply body:
{
"SnapshotID": "0c982ca3-621f-40e9-9c6e-96492934170a",
"Comment": "My user comment",
"State": "Completed",
"ExpiresOn": 1530868721000,
"CreatedOn": 1523006321000,
"ModelVersion": "1.0.11.50"
}
- Prepare a download package HTTP Method: GET URL: https://deploy.mendix.com/api/1/apps/{AppId}/environments/{Environment}/snapshots/{SnapshotId} Headers: Content-Type: application/json Mendix-Username: {Your username} Mendix-ApiKey: {Your ApiKey}
Reply body:
{
"FilesOnly": "https://cloud.home.mendix.com/backups/d4bf9d5d-cf3e-4561-9f7f-31b1c580a3d5",
"DatabaseOnly": "https://cloud.home.mendix.com/backups/5524ec0b-fdf1-460b-87c2-75bb06ec98ff",
"DatabaseAndFiles": "https://cloud.home.mendix.com/backups/24783a6c-30c4-49b4-8cb9-13b57cfec4cc"
}
- Download the package wget