Skip to main content

Database Import/Export

Appliku provides a built-in PostgreSQL migration tool for copying data between database instances. You can also perform manual imports and exports using standard PostgreSQL tools.

Built-in Migration Tool

Appliku has a built-in tool for migrating data between PostgreSQL instances managed by Appliku. This is useful when:

  • Moving an application to a different server
  • Upgrading to a newer PostgreSQL version
  • Copying data from a staging to production database (or vice versa)

To use the migration tool:

  1. Open the Appliku dashboard
  2. Navigate to the database you want to migrate
  3. Use the Migrate option to copy data to another Appliku-managed PostgreSQL instance
  4. Appliku handles the pg_dump and psql steps automatically

Manual Export (pg_dump)

To export a PostgreSQL database manually, use pg_dump via Docker. The connection URL is available in your application's environment variables.

Export to a compressed file

docker run --rm postgres:16 sh -c \
"pg_dump --no-privileges --no-owner --no-acl <postgresql_url> | gzip" > backup.sql.gz

Export to a plain SQL file

docker run --rm postgres:16 sh -c \
"pg_dump --no-privileges --no-owner --no-acl <postgresql_url>" > backup.sql

The flags used:

  • --no-privileges -- Excludes permission statements from the dump
  • --no-owner -- Excludes ownership information
  • --no-acl -- Excludes access control lists

These flags make the dump portable across different PostgreSQL instances where usernames and roles may differ.

Manual Import (psql)

Import from a compressed file

gunzip backup.sql.gz
psql <target_postgresql_url> < backup.sql

Import from a plain SQL file

psql <target_postgresql_url> < backup.sql

Import via Docker

If psql is not installed locally, use Docker:

docker run --rm -v $(pwd):/data postgres:16 sh -c \
"psql <target_postgresql_url> < /data/backup.sql"

Importing from an External Database

To import data from a database hosted outside Appliku (e.g., AWS RDS, Heroku, a VPS):

  1. Export from the external database:

    pg_dump --no-privileges --no-owner --no-acl <external_postgresql_url> | gzip > export.sql.gz
  2. Get the Appliku database URL from your application's environment variables in the dashboard

  3. Import into the Appliku database:

    gunzip export.sql.gz
    psql <appliku_postgresql_url> < export.sql
note

Ensure the PostgreSQL versions are compatible. Importing a dump from a newer PostgreSQL version into an older one may fail. When in doubt, use the same major version for both source and target.

Tips

  • Large databases: For large exports, use the custom format (-Fc) with pg_dump and restore with pg_restore for parallel processing:

    pg_dump -Fc --no-privileges --no-owner --no-acl <url> > backup.dump
    pg_restore -d <target_url> --no-privileges --no-owner --no-acl backup.dump
  • Schema only: Export just the schema without data using --schema-only:

    pg_dump --schema-only --no-privileges --no-owner <url> > schema.sql
  • Single table: Export a specific table with -t:

    pg_dump -t my_table --no-privileges --no-owner <url> > table.sql

Next Steps