How to migrate data via backup/restore¶
Charmed PostgreSQL can restore backups of itself stored on S3-compatible storage (See: How to restore a local backup). A similar restore approach is applicable for backups made by a different Charmed PostgreSQL installation or even another PostgreSQL charm. (See: How to migrate a cluster).
This is a guide for migrating data from modern charms.
Always try this in a test environment before performing it in production!
This page describes the general approach for data migration. Canonical does not guarantee restoration results.
Contact us for more guidance.
Prerequisites¶
Check your application’s compatibility with Charmed PostgreSQL before migrating production data
Make sure PostgreSQL versions are identical before the migration
Migrate database data¶
Below is the general approach to the migration:
Retrieve root/admin level credentials from the older charm.
See examples in Migrate data via pg_dump.
Install pgBackRest inside the old charm OR nearby.
Ensure the version is compatible with pgBackRest in the new Charmed PostgreSQL revision you are going to deploy! See examples in the pgBackRest user guide .
You can use the
charmed-postgresqlsnap (VM) or rock (K8s) directly.Configure storage for database backup (local or remote, S3-based is recommended).
Create a first full logical backup during the off-peak
See an example of a backup command here .
{ref}`Restore the remote backup
to the Charmed PostgreSQL installation in your test environment. Perform all the necessary tests to make sure your application accepted the new database.
Schedule and perform the final production migration, re-using the last steps above.