Data Management
This page describes how CCC stores persistent data and how to back up and restore the CCC database. It explains the persistence mechanisms used by different deployment platforms and outlines the procedures for protecting and recovering CCC data.
Persistence
CCC supports data persistence using mounted storage.
Bind Mount
The default persistence mechanism used by CCC is a bind mount, where the CCC container mounts a file or directory from the host system into the container’s file system. This allows the container to access and modify data as if it were part of its own file system. Any changes made by the container are reflected on the host machine, ensuring that data persists even if the container is stopped or deleted.
Podman
For users who have installed the CCC database using Podman, the /usr/safenet/db/data directory inside the CCC database container is mapped to the /home/ccc/pgdata directory on the host machine. The entire CCC database is stored in the pgdata directory. When the CCC container is initialized, it reads the volume mapping defined in the ccc_config.env file and begins persisting database data according to the specified configuration.
You can change the directory mapped on the host machine by modifying the ccc_config.env file.
Kubernetes/Helm
When CCC is deployed using Kubernetes or Helm, the PostgreSQL data directory (/usr/safenet/db/data) inside the container is mapped to the /home/ccc/pgdata directory on the host machine. This pgdata directory stores the entire CCC database, ensuring that database data persists independently of the container lifecycle.
The PersistentVolume and PersistentVolumeClaim resources defined in pv-pvc.yaml provide durable storage for the PostgreSQL data directory. During container initialization, Kubernetes mounts this storage into the PostgreSQL container, allowing database data to persist across container restarts, upgrades, and redeployments.
You can change the directory mapped on the host machine by modifying the pv-pvc.yaml file.
Backup and Restore
The approach used to back up and restore CCC data depends on whether CCC is deployed with an internal database or an external database. Backup and restore procedures also vary based on the deployment platform, such as Podman or Kubernetes.
CCC Internal Database: Backup and Restore
When CCC operates with an internal database, it uses a PostgreSQL database running in the CCC container. Data persistence is handled through a bind mount that maps the PostgreSQL data directory to the host machine.
Backup
To back up the CCC internal database, perform the following steps.
Create a database dump file.
Podman
podman exec ccc-db bash -c "pg_dump 'host=localhost port=5432 dbname=lunadirectordb user=lunadirector password=<dbpassword>' > /usr/safenet/db/postgres.sql"
Kubernetes
kubectl exec <postgres-podname> -- bash -c "pg_dump 'host=localhost port=5432 dbname=lunadirectordb user=lunadirector password=<dbpassword>' > /usr/safenet/db/postgres.sql"
Copy the dump file from the container to the host machine for safekeeping.
Podman
podman cp ccc-db:/usr/safenet/db/postgres.sql .
Kubernetes
kubectl cp <postgres-podname>:/usr/safenet/db/postgres.sql .
Restore
Restoring data involves importing the previously created database dump file.
Copy the backup file into the CCC-DB container.
Podman
podman cp postgres.sql ccc-db:/usr/safenet/db/
Kubernetes
kubectl cp postgres.sql <postgres-podname>:/usr/safenet/db/
Restore the database by importing the SQL dump.
Podman
podman exec ccc-db bash -c 'psql -h <postgres IP> -p <portNumber> -f /usr/safenet/db/postgres.sql -U lunadirector lunadirectordb'
Kubernetes
kubectl exec <postgres-podname> -- bash -c 'psql -h <postgres IP> -p <portNumber> -f /usr/safenet/db/postgres.sql -U lunadirector lunadirectordb'
If the CCC administrator password contains special characters, they must be escaped. For example, if the password is Ab@C$123!, enter it as Ab\@C\$123\!.
CCC External Database: Backup and Restore
If CCC is deployed with an external PostgreSQL database, backup and restore operations must be performed directly on the external database using standard PostgreSQL tools and procedures. Refer to the official PostgreSQL documentation for detailed instructions.