You can back up and restore the DataClarity database by copying the postgres pvc folder. If you are migrating the database to another server, see Back up and restore Postgresql DB via pg_dump.
Create a backup
- Connect to the VM where the DataClarity platform is installed, and then go to the microk8s default storage location:
The folder containing the postgres data starts with ‘default-postgres-pv-claim-pvc’.
Note: To access, copy, or delete the folder, you will likely need to switch to the superuser (root). To switch to the superuser, find the corresponding command for your OS. For example, the sudo su command is used in Ubuntu.
- Create a copy of the folder with the postgres pv, where /home/user/pgbackup is the location of the new copy that you can change as needed:
cp -a default-postgres-pv-claim-pvc-910fec3c-89f8-4191-86ab-fd5d587ec7d5/ /home/user/pgbackup/default-postgres-pv-claim-pvc-910fec3c-89f8-4191-86ab-fd5d587ec7d5
Note: In the above example, the folder name is default-postgres-pv-claim-pvc-910fec3c-89f8-4191-86ab-fd5d587ec7d5. In your case, it will be different, but it always starts with ‘default-postgres-pv-claim-pvc’.
Restore the backup
Go to the default storage location and record the name of the folder containing the postgres pv:
Then, delete the folder with the postgres pv:
rm -rf default-postgres-pv-claim-pvc-910fec3c-89f8-4191-86ab-fd5d587ec7d5
Copy the backup folder back into the default storage location:
cp -a /home/user/pgbackup/default-postgres-pv-claim-pvc-910fec3c-89f8-4191-86ab-fd5d587ec7d5 /var/snap/microk8s/common/default-storage/default-postgres-pv-claim-pvc-910fec3c-89f8-4191-86ab-fd5d587ec7d5