Skip to main content

The most recent patch for this version is 7.6.1.  Learn more  

Version: 7.6

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.

    pg_dump asm > /var/run/postgresql/asm.sql
    pg_dump keycloak > /var/run/postgresql/keycloak.sql
    pg_dump domain_manager > /var/run/postgresql/domain_manager.sql
    pg_dump pd > /var/run/postgresql/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>:var/run/postgresql/asm.sql ./asm.sql
    kubectl cp axiomatics-asm/<db_pod_name>:var/run/postgresql/keycloak.sql ./keycloak.sql
    kubectl cp axiomatics-asm/<db_pod_name>:var/run/postgresql/domain_manager.sql ./domain_manager.sql
    kubectl cp axiomatics-asm/<db_pod_name>:var/run/postgresql/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. If the db Pod hasn't started automatically:

    1. SSH to minikube, update the permissions, and exit.

      Important

      Run each of the following commands individually.

      minikube ssh
      sudo -i
      cd /tmp/hostpath-provisioner/axiomatics-asm
      chown -R 999:999 db/
      exit
      exit
    2. Start the db Pod manually.

      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>:run/postgresql/asm.sql 
    kubectl cp ./keycloak.sql axiomatics-asm/<db_pod_name>:run/postgresql/keycloak.sql
    kubectl cp ./domain_manager.sql axiomatics-asm/<db_pod_name>:run/postgresql/domain_manager.sql
    kubectl cp ./pd.sql axiomatics-asm/<db_pod_name>:run/postgresql/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.

    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 < /run/postgresql/asm.sql
    psql keycloak < /run/postgresql/keycloak.sql
    psql domain_manager < /run/postgresql/domain_manager.sql
    psql pd < /run/postgresql/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