Back up Audit PostgreSQL

This guide shows you the procedure to backup your Audit PostgreSQL database on your Rhize Kubernetes deployment.

Prerequisites

Before you start, ensure you have the following:

  • A designated backup location, for example ~/rhize-backups/libre-audit.
  • Access to the Rhize Kubernetes Environment
  • Optional: kubectx utilities
    • kubectx to manage multiple clusters
    • kubens to switch between and configure namespaces easily
  • Optional: the k8 Lens IDE, if you prefer to use Kubernetes graphically

Also, before you start, confirm you are in the right context and namespace.

## context
kubectl config current-context
## namespace
kubectl get namespace

To change the namespace for all subsequent kubectl commands to libre, run this command:

kubectl config set-context --current --namespace=libre

Steps

To back up Audit PostgreSQL, follow these steps:

  1. Check the logs for the Audit pods, either in Lens or with kubectl logs. Ensure there are no errors.

  2. Retrieve the Audit user password using the following command:

    kubectl get secret <SECRET-NAME> -o jsonpath="{.data.<SECRET-KEY>}" | base64 --decode
  3. Execute a command on the Audit Postgres pod to perform a full backup:

    kubectl exec -i audit-postgres-0 -- pg_dumpall -U <DB_USER> | gzip > audit-postgres-backup-$(date +"%Y%m%dT%I%M%p").sql.gz

On success, the backup creates a GZIP file, audit-postgres-backup-YYYYMMDDTHHMMSS.sql.gz. To check that the backup succeeded, unzip the files and inspect the data.

Next Steps