Backing up and restoring data
Database configuration required
These procedures apply only if you completed the Preparing the database step. If you deploy the IQ backend server without a database, skip this section. For deployment options without a database, refer to Limitations.
If you configured a PostgreSQL database, the IQ backend server stores session and conversation data in that instance. Run regular backups to ensure data recovery if a failure occurs.
Prerequisites
Verify that persistence-node pods are in the Running state:
kubectl get pods -n <YOUR_NAMESPACE> | grep persistence-node
Multiple persistence-node pods might run:
NAME READY STATUS RESTARTS AGE
dx-deployment-persistence-node-0 2/2 Running 0 3h49m
dx-deployment-persistence-node-1 2/2 Running 0 3h48m
dx-deployment-persistence-node-2 2/2 Running 0 3h48m
Backing up persistence data
Backing up persistence data secures the session information and chat history data managed by the IQ backend server. Regular backups prevent data loss during unexpected system failures, cluster migrations, or application upgrades.
-
Identify the primary
persistence-nodepod:kubectl -n <YOUR_NAMESPACE> exec pod/<DX_RELEASE_NAME>-persistence-node-0 -c persistence-node -- \ repmgr cluster show --compact --terse 2>/dev/null | grep "primary" | awk '{split($0,a,"|"); print a[2]}' | xargs<YOUR_NAMESPACE>: The Kubernetes namespace.<DX_RELEASE_NAME>: The HCL Digital Experience deployment name.
Example output:
dx-deployment-persistence-node-0Use this node name as
<PRIMARY_NODE_NAME>in the following steps. -
Back up the current database contents by generating a dump file inside the pod:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ /bin/bash -c "pg_dump iqdb > /tmp/iqdb.dmp" -
Verify that the dump file exists in the pod and contains data:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ ls -lh /tmp/iqdb.dmpExample output:
-rw-r--r--. 1 dx_user dx_users 125K Mar 31 17:22 /tmp/iqdb.dmp -
Download the database dump file to the local environment:
-
To download the uncompressed dump file directly, run this command:
kubectl cp -n <YOUR_NAMESPACE> -c persistence-node \ <PRIMARY_NODE_NAME>:/tmp/iqdb.dmp ./iqdb-backup-$(date +%Y%m%d).dmp -
To compress the file before downloading, run these commands:
# Compress in the pod kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ gzip /tmp/iqdb.dmp # Download compressed file kubectl cp -n <YOUR_NAMESPACE> -c persistence-node \ <PRIMARY_NODE_NAME>:/tmp/iqdb.dmp.gz ./iqdb-backup-$(date +%Y%m%d).dmp.gz
-
-
Move the backup file to a secure, off-cluster location:
# Example: Copy to remote storage scp ./iqdb-backup-$(date +%Y%m%d).dmp.gz user@backup-server:/backups/dx-iq/
Restoring persistence data
Restoring persistence data reconstructs session information and conversation history from a saved database dump file. This procedure is required during system recovery, database failures, or cluster migrations.
-
Identify the primary
persistence-nodepod:kubectl -n <YOUR_NAMESPACE> exec pod/<DX_RELEASE_NAME>-persistence-node-0 -c persistence-node -- \ repmgr cluster show --compact --terse 2>/dev/null | grep "primary" | awk '{split($0,a,"|"); print a[2]}' | xargsExample output:
dx-deployment-persistence-node-0Use this node name as
<PRIMARY_NODE_NAME>in the following steps. -
Upload the dump file to the primary
persistence-nodepod:-
To upload an uncompressed dump file, run this command:
kubectl cp -n <YOUR_NAMESPACE> -c persistence-node \ ./iqdb-backup-20260518.dmp <PRIMARY_NODE_NAME>:/tmp/iqdb.dmp -
To upload and decompress a compressed file, run these commands:
# Upload compressed file kubectl cp -n <YOUR_NAMESPACE> -c persistence-node \ ./iqdb-backup-20260518.dmp.gz <PRIMARY_NODE_NAME>:/tmp/iqdb.dmp.gz # Decompress in the pod kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ gunzip /tmp/iqdb.dmp.gz
-
-
Verify that the dump file exists in the pod:
-
Check that the dump file exists:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ ls -lh /tmp/iqdb.dmp -
Inspect the first 20 lines of the file to verify the contents:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ head -n 20 /tmp/iqdb.dmpThe output contains SQL statements such as
CREATE TABLEandINSERT INTO.
-
-
Set the database connection limit to
0:kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ psql -c "ALTER DATABASE iqdb CONNECTION LIMIT 0;" -
Terminate the existing active connections to the database:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'iqdb' AND pid <> pg_backend_pid();" -
Drop the existing database:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ dropdb iqdbWarning
If an error indicates that the database is being accessed by other users, repeat Steps 4 through 6 until the database drops successfully.
-
Create a new, empty database:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ /bin/bash -c "createdb -O dxuser iqdb" -
Restore the database from the backup file:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ /bin/bash -c "psql iqdb < /tmp/iqdb.dmp"Expected output should show SQL statements being executed:
SET SET CREATE TABLE ALTER TABLE COPY 37 REVOKE GRANTThe
COPYstatements indicate that records are inserting into the database tables. -
Restore the database connection limit to the standard configuration:
kubectl -n <YOUR_NAMESPACE> exec pod/<PRIMARY_NODE_NAME> -c persistence-node -- \ psql -c "ALTER DATABASE iqdb CONNECTION LIMIT 500;"
Completing post-restore recovery
The persistence connection pool restarts after the database restoration completes. If the IQ service fails to recover automatically, perform these steps to restart the service components:
-
Delete the IQ integrator pod to trigger a restart:
kubectl delete pod -n <YOUR_NAMESPACE> -l app=dx-iq-integratorKubernetes automatically recreates the pod.
-
Verify the operational status of the new pod:
kubectl get pods -n <YOUR_NAMESPACE> | grep dx-iq-integratorEnsure that the pod status reaches the
Runningstate and displays1/1in theReadycolumn.
Validation
After configuring your database, validate your deployment to verify that the IQ pod can connect to the database successfully.