Only Certificate Hub installations migrated from older versions support an internal database—that is, a database running on the same host as the application. See below for switching from an internal database to an external one.

Run the steps below in the same version of Certificate Hub that will use the database.

Exporting the database contents

Set the following environment variables in the host running the internal database.

Variable

Value

KUBECTL

​The value of the KUBECTL parameter described in Configuring the deployment.

NAMESPACE

The value of the NAMESPACE parameter described in Configuring the deployment.

POSTGRES_DB

certhub

POSTGRES_PWD

The value of the POSTGRES_PWD parameter described in Configuring the deployment.

POSTGRES_USER

The value of the POSTGRES_USER parameter described in Configuring the deployment.

Run the following commands.

now=$(date +"%m_%d_%Y")
$KUBECTL exec deployment/postgres -n "$NAMESPACE" -- bash -c "export PGPASSWORD=$POSTGRES_PWD; pg_dump -d $POSTGRES_DB -U $POSTGRES_USER" > "db-backup-$now.sql"

Restoring the database contents

Perform the following steps on an external host to restore the database contents.

To restore the database contents on an external host

  1. Install the PostgreSQL version described in Database requirements.
  2. Copy the db-backup-<date>.sql backup file generated when Exporting the database contents.
  3. Set the following environment variables to the values described in Exporting the database contents.
    • POSTGRES_DB
    • POSTGRES_PWD
    • POSTGRES_USER 
  4. Run the following command. 
    export PGPASSWORD=$POSTGRES_PWD; psql -d $POSTGRES_DB -U $POSTGRES_USER -f db-backup-<date>.sql

Applying the database changes to Certificate Hub

Complete the database migration by performing the following operations on the Certificate Manager host.

To apply the database changes to Certificate Hub

  1. Update the database configuration parameters described in Configuring the deployment to match the new external database.
  2. Redeploy Certificate Hub to make the changes effective.
  3. Wait while the redeployment with the external database is complete.
  4. Manually remove the PostgreSQL pod.