Back up and restore a DAM image
This topic shows you how to backup and restore for Digital Asset Management persistence
and binaries in an Operator-based deployment using dxctl
.
About this task
Note: The steps in this section are supported for HCL DX 9.5 Container Update CF195 or
later deployments. Please contact HCL Support if you need to perform backup/restore for
container deployments at earlier levels.
- Back up your database
-
- Verify that persistence (read-write) and DAM pods are up and
running:
kubectl -n <namespace> get all
Example:kubectl -n dxns get all
- Disable the persistence read-only pods by setting the following properties in the
deployment properties
file:
persist.minreplicas: 1 persist.force-read: false
Then run the following command:dxctl --update -p deployment.properties
Note: Verify that there are no read-only pods in the deployment. - Connect with the persistence pod (read-write). Open a shell in the running
persistence pod:
kubectl exec --stdin --tty pod/<pod-name> -n <namespace> -- /bin/bash
Example:kubectl exec --stdin --tty pod/dx-deployment-persistence-0 -n dxns -- /bin/bash
- Dump the current
database:
pg_dump dxmediadb > /tmp/dxmediadb.dmp
- Close the shell in the persistence pod:
exit
- Dump the current
database:
- Download the database dump to the local
system:
kubectl cp <namespace>/<pod-name>:<source-file> <target-file>
Example:kubectl cp dxns/dx-deployment-persistence-0:/tmp/dxmediadb.dmp /tmp/dxmediadb.dmp
- Verify that persistence (read-write) and DAM pods are up and
running:
- Back up your DAM binary
-
- Connect to the DAM pod. Open a shell in the running DAM
pod:
kubectl exec --stdin --tty pod/<pod-name> -n <namespace> -- /bin/bash
Example:kubectl exec --stdin --tty pod/dx-deployment-dam-0 -n dxns -- /bin/bash
- Compress the DAM binaries located under /opt/app/upload
directory:
tar -cvpzf backupml.tar.gz --exclude=/backupml.tar.gz --one-file-system --directory /opt/app/upload .
- Close the shell in the DAM pod:
exit
- Download the compressed binaries to the local system.
From a local system, you can now download the backup DAM binaries from the DAM pod:
kubectl cp <namespace>/<pod-name>:<source-file> <target-file>
Example:
kubectl cp dxns/dx-deployment-dam-0:/opt/app/server-v1/backupml.tar.gz /tmp/backupml.tar.gz
- Connect to the DAM pod. Open a shell in the running DAM
pod:
- Restore your DAM binary
-
- Upload the backup binary to the DAM pod. You can now transfer the backup database
to the remote DAM
pod:
kubectl cp <source-file> <namespace>/<pod-name>:<target-file>
Example:kubectl cp /tmp/backupml.tar.gz dxns/dx-deployment-dam-0:/tmp/backupml.tar.gz
- Connect to the DAM pod. Use the following command to open a shell in the running
DAM
pod:
kubectl exec --stdin --tty pod/<pod-name> -n <namespace> -- /bin/bash
Example:kubectl exec --stdin --tty pod/dx-deployment-dam-0 -n dxns -- /bin/bash
- Restore the DAM
binaries:
tar -mpxf /tmp/backupml.tar.gz --directory /opt/app/upload rm /backupml.tar.gz
- Close the shell in the DAM pod:
exit
- Upload the backup binary to the DAM pod. You can now transfer the backup database
to the remote DAM
pod:
- Restore your database
-
- Verify that persistence (read-write) and DAM pods are
running:
kubectl -n <namespace> get all
Example:kubectl -n dxns get all
- Copy the database dump file to the persistence
pod:
kubectl cp <target-file> <namespace>/<pod-name>:<target-file>
Example:kubectl cp dxmediadb.dmp dxns/dx-deployment-persistence-0:/tmp/dxmediadb.dmp
- Connect to the persistence pod (read-write). Open a shell in the running
persistence
pod:
kubectl exec --stdin --tty pod/<pod-name> -n <namespace> -- /bin/bash
Example:kubectl exec --stdin --tty pod/dx-deployment-persistence-0 -n dxns -- /bin/bash
- Run the following commands in order:
- Set the database connection limit to 0 for
dxmediadb
:psql -c "ALTER DATABASE dxmediadb CONNECTION LIMIT 0;"
- Terminate all the existing connections to the database, if
any:
psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'dxmediadb' AND pid <> pg_backend_pid();"
- Drop the database
dxmediadb
:dropdb dxmediadb
Note: If you are getting the following error, run the two commands from this step again until it completes without the error occurring.``` dropdb: database removal failed: ERROR: database "dxmediadb" is being accessed by other users ```
- Set the database connection limit to 0 for
- Create the database.
createdb -O dxuser dxmediadb
- Restore the
database.
psql dxmediadb < dxmediadb.dmp
- Restore the database connection
limit:
psql -c "ALTER DATABASE dxmediadb CONNECTION LIMIT 500;"
- Close the shell in the persistence pod
(read-write):
exit
- Run the following commands in order:
- Verify that persistence (read-write) and DAM pods are
running:
- Additional steps to restore your database
-
- The DAM pods start working in a few minutes. If not, you may delete the DAM
pod:
kubectl delete pod <dam-pod-name> -n <namespace>
Example:kubectl delete pod dx-deployment-dam-0 -n dxns
- You must reset the read-only pod. Do the following steps:
- Get all the
PersistentVolumeClaim
(PVC
) from the deployment.kubectl get pvc -n <name space>
Example:kubectl get pvc -n dxns
- Delete the
PVC
for the read-only pods.kubectl delete pvc <pvc-name-for-read-only-pod> -n <namespace>
Example:kubectl delete pvc dam-persistence-dx-deployment-persistence-ro-0 -n dxns
- Enable the read-only pods. To enable the read-only pods, set
persist.force-read
totrue
in deployment properties file. You may also update thepersist.minreplicas:
with the value you configured earlier.persist.minreplicas: 1 persist.force-read: true
Then run the following command:
dxctl --update -p deployment.properties
- Get all the
- The DAM pods start working in a few minutes. If not, you may delete the DAM
pod: