Skip to main content

Overview

This guide walks you through migrating your data from a self-hosted Blnk Core instance to a hosted Core instance managed by Blnk. The migration process involves exporting data from your self-hosted PostgreSQL database and importing it into your Cloud-hosted database with Blnk.

Prerequisites

The migration process may take several hours depending on your database size. Plan for downtime during the migration window.
Before starting the migration:
  • Deploy Core on Blnk Cloud: Deploy a new managed Core instance on Blnk Cloud. See the Managed Instances guide to get started.
  • Install PostgreSQL: Ensure that PostgreSQL is installed on your terminal.
  • Self-hosted database access: You have access and connection details (username, password, host, port, and database name) to your self-hosted database.

Migration process

1

Dump your self-hosted database

Export your self-hosted database data to a custom format file:
export PGPASSWORD='<SOURCE_DB_PASSWORD>'

pg_dump \
  -h <SOURCE_DB_HOST> \
  -p <SOURCE_DB_PORT> \
  -U <SOURCE_DB_USER> \
  -d <SOURCE_DB_NAME> \
  -Fc \
  --data-only \
  --no-owner \
  --no-privileges \
  --exclude-table=blnk.transaction_journal \
  --exclude-table=blnk.gorp_migrations \
  > blnk_data.dump
You can check that it’s been created by running:
ls -lh blnk_data.dump
2

Generate DB access for your Cloud-hosted instance

Generate database access credentials for your hosted instance. See also: Direct DB access guide.Generate direct DB access to your instance
Whitelist your IP address first: Before generating DB access, make sure to whitelist your IP address. This is required for database connections. See the IP Whitelisting guide for details.
3

Delete existing default rows from your Cloud-hosted DB

Connect to the hosted database via psql:
export PGPASSWORD='<CLOUD_DB_PASSWORD>'

psql "host=<CLOUD_DB_HOST> port=25060 dbname=blnk user=<CLOUD_DB_USER> sslmode=require"
Delete the default ledger from the hosted instance to prevent duplicate conflicts when copying data from your source database:
DELETE FROM blnk.ledgers;
Exit psql using \q.
4

Import your data into your Cloud-hosted DB

Run the following command from the folder containing the blnk_data.dump file:
export PGPASSWORD='<CLOUD_DB_PASSWORD>'

pg_restore \
  --data-only \
  --no-owner \
  --no-privileges \
  --verbose \
  --dbname="postgresql://<CLOUD_DB_USER>@<CLOUD_DB_HOST>:25060/blnk?sslmode=require" \
  blnk_data.dump
Depending on the size of your data, the import process may take a while. The --verbose flag will show progress as the data is imported.
5

Verify that everything works fine

On your Cloud workspace:
  1. Confirm that you can see all the records in your data.
  2. Confirm that the record counts match between both databases.
  3. Confirm that you can create/update records via the API or dashboard.

Need help?

If you’re having trouble with Blnk Cloud, don’t hesitate to send us a message via email at [email protected] or send us a message here.