Skip to content

PaaS environment export/import for portability — JSON envelope, data volumes, secrets

What an exported PaaS environment definition actually contains, what it deliberately omits, and how to re-import it cleanly on a different region or different PaaS instance.

You’ve been running on one PaaS provider for two years and need to move the environment to another hoster, or to a different region under the same hoster, or simply produce an offline-readable definition of what’s running so a new engineer can reason about it. The PaaS panel offers “Export environment” and produces a JSON file. You drop the JSON on the destination, click Import, and the environment doesn’t come up because two services that the source provider had pre-installed aren’t available on the destination, the SSL add-on settings reference an internal ID that’s specific to the source, and none of the persistent data made it across because the export was definition-only.

What’s happening

A PaaS environment export is a declarative manifest of the topology — what nodes, what software stack, what env vars, what add-ons — in a JSON envelope (Jelastic calls this the JPS / JelasticPackagingStandard format, or a derived “environment manifest” depending on version). The manifest is portable; the data is not in the file.

Specifically:

  • Topology: node groups, image tags, cloudlet sizing, scaling triggers, links between nodes. Yes, in the envelope.
  • Environment variables defined on the node group: yes, in the envelope, but secrets you marked as “protected” are masked — they come out as *** and have to be re-set on import.
  • Add-on installations: yes, but the add-on must exist on the destination provider’s marketplace. Hoster-specific add-ons (a custom Let’s Encrypt fork, a hoster’s monitoring agent) will fail at import.
  • Custom domains and SSL certs: domain binding entries yes, certificates no.
  • Persistent storage data: never in the export. The envelope describes that a storage node exists with a 100GB disk; the 100GB of files have to travel separately.
  • Database content: a manifest references that you have a MySQL node group; the data lives inside that node’s volume and is not in the JSON.
  • Cron jobs added to the cron add-on: yes. Cron jobs added directly via crontab -e on a container: no.
  • Service-account API keys or webhooks baked into env vars: in the JSON, in cleartext, unless they were marked protected. That’s a security consideration when handing the export to anyone.

The mental model: the export gives you a recipe for the infrastructure shape. Data, secrets, and certificates are operational state that travels through different channels.

How to verify

Get the export and inspect what came across:

# Export to JSON
jelastic-cli environment Export ExportEnv \
  --envName acme-prod \
  > acme-prod-manifest.json

# Or via the REST API
curl -s -X POST "https://app.${HOSTER_DOMAIN}/1.0/environment/export/rest/exportenv" \
  -d "session=${SESSION}&envName=acme-prod" \
  -o acme-prod-manifest.json

# Audit what's in the envelope
jq '.nodes[]|{nodeGroup,nodeType,cloudlets,image:.metadata.image,vars:.envVars}' \
  acme-prod-manifest.json

# Find masked secrets that will need to be re-set
jq -r '.nodes[].envVars|to_entries[]|select(.value=="***")|.key' \
  acme-prod-manifest.json

# Find add-ons that the destination provider must support
jq -r '.nodes[].addons[]?.name' acme-prod-manifest.json | sort -u

Run the add-on list against the destination provider’s marketplace before attempting import. If lets-encrypt-ssl-addon exists on source and the destination ships only acme-ssl-addon, that’s an import-time failure waiting to happen.

For the data-portability side, list what isn’t in the export:

# Inventory persistent volumes on source
jelastic-cli environment Control ExecCmdByGroup \
  --envName acme-prod --nodeGroup storage \
  --commandList '[{"command":"df -h /data && du -sh /data/*"}]'

# Inventory database sizes
jelastic-cli environment Control ExecCmdByGroup \
  --envName acme-prod --nodeGroup sqldb \
  --commandList '[{"command":"mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e \"SELECT table_schema, ROUND(SUM(data_length+index_length)/1024/1024,2) AS MB FROM information_schema.tables GROUP BY table_schema\""}]'

This list is the data-migration scope. The JSON manifest doesn’t know about any of it.

The fix

Treat the manifest as one of three artifacts you need to produce, not the only one. A clean export/import runbook:

#!/usr/bin/env bash
set -euo pipefail

SOURCE_ENV="acme-prod"
TARGET_ENV="acme-prod-eu"

mkdir -p /tmp/export
cd /tmp/export

echo "==> 1. Manifest"
jelastic-cli environment Export ExportEnv \
  --envName "${SOURCE_ENV}" > manifest.json

# Clean references to hoster-specific internal IDs that won't resolve on target
jq 'del(.nodes[]?.ips, .nodes[]?.nodeId, .hardwareNodeGroup)' manifest.json \
  > manifest.clean.json

echo "==> 2. Secrets that were masked"
# Produce a list to be re-set manually on import
jq -r '.nodes[]|{group:.nodeGroup,vars:.envVars|to_entries[]|select(.value=="***")|.key}' \
  manifest.json > secrets-to-reset.txt
echo "Re-set the following on the target environment before first boot:"
cat secrets-to-reset.txt

echo "==> 3. Persistent data dumps"
# Database dump
jelastic-cli environment Control ExecCmdByGroup \
  --envName "${SOURCE_ENV}" --nodeGroup sqldb \
  --commandList '[{"command":"mysqldump --single-transaction --quick --routines --triggers --all-databases | gzip > /tmp/all-dbs.sql.gz"}]'
jelastic-cli environment File Download \
  --envName "${SOURCE_ENV}" --nodeGroup sqldb \
  --path /tmp/all-dbs.sql.gz --dest /tmp/export/all-dbs.sql.gz

# Persistent storage tarball
jelastic-cli environment Control ExecCmdByGroup \
  --envName "${SOURCE_ENV}" --nodeGroup storage \
  --commandList '[{"command":"tar czf /tmp/data.tar.gz -C /data ."}]'
jelastic-cli environment File Download \
  --envName "${SOURCE_ENV}" --nodeGroup storage \
  --path /tmp/data.tar.gz --dest /tmp/export/data.tar.gz

echo "==> 4. Import on target"
jelastic-cli environment Export ImportEnv \
  --jsonData "$(cat manifest.clean.json)" \
  --envName "${TARGET_ENV}" \
  --region default

echo "==> 5. Re-set secrets"
# Loop over secrets-to-reset.txt; prompt or read from your secret manager
while IFS= read -r line; do
  group=$(echo "$line" | jq -r '.group')
  key=$(echo "$line" | jq -r '.vars')
  val=$(secret-cli get "acme/${TARGET_ENV}/${key}")
  jelastic-cli environment Control AddContainerEnvVars \
    --envName "${TARGET_ENV}" --nodeGroup "${group}" \
    --vars "{\"${key}\":\"${val}\"}"
done < secrets-to-reset.txt

echo "==> 6. Restore data"
jelastic-cli environment File Upload \
  --envName "${TARGET_ENV}" --nodeGroup sqldb \
  --sourcePath /tmp/export/all-dbs.sql.gz --path /tmp/all-dbs.sql.gz
jelastic-cli environment Control ExecCmdByGroup \
  --envName "${TARGET_ENV}" --nodeGroup sqldb \
  --commandList '[{"command":"zcat /tmp/all-dbs.sql.gz | mysql -uroot -p${MYSQL_ROOT_PASSWORD}"}]'

jelastic-cli environment File Upload \
  --envName "${TARGET_ENV}" --nodeGroup storage \
  --sourcePath /tmp/export/data.tar.gz --path /tmp/data.tar.gz
jelastic-cli environment Control ExecCmdByGroup \
  --envName "${TARGET_ENV}" --nodeGroup storage \
  --commandList '[{"command":"tar xzf /tmp/data.tar.gz -C /data"}]'

echo "==> 7. Re-issue SSL on target hostname"
jelastic-cli marketplace Installation Install \
  --envName "${TARGET_ENV}" --jps lets-encrypt-ssl-addon \
  --settings "{\"externaldomains\":\"www.acme.tld\"}"

echo "==> 8. Smoke and cut DNS"

Two operational habits make this less painful next time. First, keep the manifest under version control: every change to the production environment (a new node group, a new env var) should be reflected by re-running export and committing the diff. Second, treat the JSON envelope as not authoritative for secrets — store secrets in a dedicated manager (Vault, your provider’s secret service, whatever you’ve standardized on) and inject them at import time. A manifest that contains live credentials in plaintext is a leak waiting for the wrong commit.

Stack Harbor runs export/import flows as part of migration projects on managed Cloud PaaS, including the three-artifact runbook (manifest, data, secrets) and a parallel-stack cutover. For an inherited environment that’s never been exported, book a portability audit.