Skip to main content
Version: 7.5

Backup & restore on Kubernetes environments

Follow the instructions below to backup and restore your Axiomatics Services Manager (ASM) Kubernetes (K8s) deployment.

Backup

Local Kubernetes (K8s) environments deployed with Minikube are intended to be used for testing purposes and their data should be non-critical and easy to regenerate. However, in order to backup the Postgres DB running on the K8s pod, follow the steps below.

note

Cloud environments are using RDS Postgres which offers the option to take backups automatically. Additionally, it is possible to take DB snapshots at any time that you can export, copy, and share. Finally, you can restore a DB from a snapshot. For more information, refer to the AWS documentationOpens in a new tab.

  1. Enter the Pod.

    kubectl exec -it deployment/db -n axiomatics-asm -- bin/bash
  2. Dump the databases.

    su - postgres
    cd /tmp
    pg_dump asm > asm.sql
    pg_dump keycloak > keycloak.sql
    pg_dump domain_manager > domain_manager.sql
    pg_dump pd > pd.sql
  3. Exit.

    exit 
    exit
  4. Copy the SQL files to the host.

    Important

    Replace the <db_pod_name> placeholders with the name of the database pod.

    kubectl cp axiomatics-asm/<db_pod_name>:tmp/asm.sql ./asm.sql 
    kubectl cp axiomatics-asm/<db_pod_name>:tmp/keycloak.sql ./keycloak.sql
    kubectl cp axiomatics-asm/<db_pod_name>:tmp/domain_manager.sql ./domain_manager.sql
    kubectl cp axiomatics-asm/<db_pod_name>:tmp/pd.sql ./pd.sql

Restore

note

In cloud environments you can restore a DB from a snapshot. See the AWS documentationOpens in a new tab for further details.

  1. Stop all Pods that use the database, including the DB Pod.

    kubectl scale --replicas 0 deployment.apps/adm -n axiomatics-asm
    kubectl scale --replicas 0 deployment.apps/asm -n axiomatics-asm
    kubectl scale --replicas 0 deployment.apps/keycloak -n axiomatics-asm
    kubectl scale --replicas 0 deployment.apps/pd-api -n axiomatics-asm
    kubectl scale --replicas 0 deployment.apps/db -n axiomatics-asm
  2. Make sure that no PersistentVolumes (PV) or PersistentVolumeClaims (PVC) related to the Postgres database exist.

    1. Check if the db PVC exists.

      kubectl get pvc --all-namespaces

      If it does, delete it.

      kubectl delete pvc db -n axiomatics-asm
    2. Check if the db PV exists.

      kubectl get pv --all-namespaces

      If it does, delete it.

      Important

      In the following command, replace <pvc_id> with the ID of the db PVC.

      kubectl delete pv <pvc_id>
  3. Upgrade the Helm charts.

    helm upgrade -n axiomatics-asm asm -f asmcharts/values.yaml asmcharts
  4. Make sure that the following Pods are not running: adm, asm, keycloak, and pd-api

    kubectl get pods -n axiomatics-asm

    If any of these Pods are still active, stop them using the following command.

    Important

    Replace <pod_name> with the actual name of the running pod. For example, adm.

    kubectl scale --replicas 0 deployment.apps/<pod_name> -n axiomatics-asm
  5. Start the db Pod manually if it hasn't already done so.

    kubectl scale --replicas 1 deployment.apps/db -n axiomatics-asm
  6. From the directory containing the backed up SQL files, copy them to the database pod.

    Important

    Replace the <db_pod_name> placeholders with the name of the database pod.

    kubectl cp ./asm.sql  axiomatics-asm/<db_pod_name>:tmp/asm.sql 
    kubectl cp ./keycloak.sql axiomatics-asm/<db_pod_name>:tmp/keycloak.sql
    kubectl cp ./domain_manager.sql axiomatics-asm/<db_pod_name>:tmp/domain_manager.sql
    kubectl cp ./pd.sql axiomatics-asm/<db_pod_name>:tmp/pd.sql
  7. Enter the Pod.

    kubectl exec -it deployment/db -n axiomatics-asm -- bin/bash
  8. Drop the databases. Then, create them again and run the SQL files.

    su - postgres
    psql template1 -c 'drop database asm'
    psql template1 -c 'drop database keycloak'
    psql template1 -c 'drop database domain_manager'
    psql template1 -c 'drop database pd'
    psql template1 -c 'create database asm'
    psql template1 -c 'create database keycloak'
    psql template1 -c 'create database domain_manager'
    psql template1 -c 'create database pd'
    psql asm < /tmp/asm.sql
    psql keycloak < /tmp/keycloak.sql
    psql domain_manager < /tmp/domain_manager.sql
    psql pd < /tmp/pd.sql
  9. Exit.

    exit 
    exit
  10. Start the Pods again.

    kubectl scale --replicas 1 deployment.apps/adm -n axiomatics-asm
    kubectl scale --replicas 1 deployment.apps/asm -n axiomatics-asm
    kubectl scale --replicas 1 deployment.apps/keycloak -n axiomatics-asm
    kubectl scale --replicas 1 deployment.apps/pd-api -n axiomatics-asm