cardinal

Connect the sites

Give the migrator read access to Frappe and write access to the Cardinal site.

A migration pairs one Frappe source with one Cardinal site. You prepare both sides, then fill in Setup and press each Test button.

Prepare the Frappe source

The migrator reads MariaDB directly. Pick one of two ways.

For repeated syncs against the live site, create a read-only user:

CREATE USER 'migrator_ro'@'%' IDENTIFIED BY '...';
GRANT SELECT, SHOW VIEW ON <db>.* TO 'migrator_ro'@'%';

For a one-time copy or a rehearsal, load a backup into a throwaway MariaDB:

# On the Frappe server
bench --site erp.example.com backup --with-files
# sites/erp.example.com/private/backups/<stamp>-database.sql.gz, -files.tar, -private-files.tar

# On the machine that runs the migrator
docker run -d --name frappe-src -p 3307:3306 -e MARIADB_ROOT_PASSWORD=root mariadb:11.4 \
  --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
gunzip < <stamp>-database.sql.gz | docker exec -i frappe-src mariadb -uroot -proot \
  -e 'CREATE DATABASE src; USE src; SOURCE /dev/stdin'

For files, point the migrator at the folder that holds the backup's -files.tar and -private-files.tar, or at an rsync of sites/SITE/{public,private}/files.

Prepare the Cardinal target

cardinal new-site HOST --install-app erp --install-app hrms --install-app gst_compliance
cardinal scheduler disable -t HOST

A sync refuses to run while the site's scheduler is on. For the report checks, make an API key as a System Manager with POST /api/auth/keys {"user": "<email>"}.

Fill in Setup

Add a migration by name on the Migrations page, then open Setup. Each section has a Test button that says what it found or what to fix. Save when every test passes.

SectionWhat to enter
Frappe sourceThe MariaDB and the read-only user. The test reports the Frappe, ERPNext and HRMS versions
Files folderThe folder with the extracted files or the backup's tar files
Cardinal targetThe site's Postgres and its host name. The test reports the installed apps and whether the scheduler is off
Target bucketCardinal's S3 endpoint, bucket and keys
Target APIThe site URL, API key and secret. Optional; the ledger and pay checks use ERP's and HRMS's reports with it
Cardinal CLIThe site checkout's bin/cardinal and the workspace folder. The migrator runs cardinal migrate and cardinal search reindex with them
KeysThe source's encryption_key and the target's CARDINAL_MASTER_KEY

Credentials and keys are stored encrypted under MIGRATOR_KEY. The UI shows them masked.

Where the keys live

The source's encryption_key is in sites/<site>/site_config.json. Frappe writes it there the first time it encrypts a Password field.

jq -r .encryption_key sites/<site>/site_config.json                   # on a bench
docker exec <backend container> cat sites/<site>/site_config.json     # in frappe_docker

Without it, encrypted fields fail with no_encryption_key.

The target's master key is the site's CARDINAL_MASTER_KEY. A cardinal init workspace keeps it in .cardinal/secrets.exs.

Without the Cardinal CLI paths, cardinal migrate is logged as failed and Jinja Print Formats arrive disabled without a parse check.

From the command line

migration add takes the same settings as flags:

FlagValue
--source-urlmysql://user:pass@host:3306/db
--filesThe files folder
--target-urlpostgres://user:pass@host:5432/db
--siteThe Cardinal site's host
--s3-endpoint, --s3-bucket, --s3-regionThe target bucket
--s3-access-key-id, --s3-secret-access-keyThe bucket's keys
--encryption-keyThe source's encryption_key
--master-keyThe target's CARDINAL_MASTER_KEY
--api-url, --api-key, --api-secretThe target API
--cardinal-bin, --cardinal-dirThe cardinal CLI and its workspace
bin/frappe-migrator migration add acme \
  --source-url mysql://migrator_ro:secret@10.0.0.5:3306/_a1b2c3 --files ./site-files \
  --target-url postgres://cardinal:secret@localhost:5432/cardinal --site erp.example.com
bin/frappe-migrator migration test acme

On this page