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.

Prerequisites


Migrate database data

Below is the general approach to the migration:

  1. Retrieve root/admin level credentials from the older charm.

    See examples in Migrate data via pg_dump.

  2. 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-postgresql snap (VM) or rock (K8s) directly.

  3. Configure storage for database backup (local or remote, S3-based is recommended).

  4. Create a first full logical backup during the off-peak

    See an example of a backup command here .

  5. {ref}`Restore the remote backup to the Charmed PostgreSQL installation in your test environment.

  6. Perform all the necessary tests to make sure your application accepted the new database.

  7. Schedule and perform the final production migration, re-using the last steps above.