# Backup Posstgres DB from cluster #1 and restore DB to cluster#2

**URL:** <https://forum.ansible.com/t/backup-posstgres-db-from-cluster-1-and-restore-db-to-cluster-2/7643>\
**Category:** Get Help\
**Tags:** kubernetes, role, documentation, awx\
**Created:** [August 5, 2024, 4:02pm UTC](https://forum.ansible.com/t/backup-posstgres-db-from-cluster-1-and-restore-db-to-cluster-2/7643 "2024-08-05T16:02:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremytourville](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jeremytourville/32/2448_2.png) [@jeremytourville](https://forum.ansible.com/u/jeremytourville)\
**Post date:** [August 5, 2024, 4:02pm UTC](https://forum.ansible.com/t/backup-posstgres-db-from-cluster-1-and-restore-db-to-cluster-2/7643/1 "2024-08-05T16:02:10Z")

</div>

I would like to understand how to backup and restore my postgres DB from one cluster to another.  
My environment:

- I am running AWX 23.7.0
- I presently have two K8s clusters running.
- AWX is running successfully in both clusters.
- I set my CNAME in DNS so that users login to the correct instance.
- postgres is running as part of an operator deployment where storage is configured on one of the specific nodes.

```auto
kubectl label nodes gsil-kube03.idm.gsil.org nodefor=psql (old cluster)
kubectl label nodes gsil-kube06.idm.gsil.org nodefor=psql (new cluster)

```

I want to backup and restore my data to the new cluster. I have been reading through documentation: [AWX Operator Role - Backup](https://github.com/ansible/awx-operator/tree/devel/roles/backup) My understanding is that this role will backup my postgres data (among other things). I am unclear how this role can be used to restore data. Is there some documentation elsewhere that I can refer to?

---

<div class="post-metadata">

**Author:** ![Klaas](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.ansible.com/u/Klaas)\
**Post date:** [August 5, 2024, 5:17pm UTC](https://forum.ansible.com/t/backup-posstgres-db-from-cluster-1-and-restore-db-to-cluster-2/7643/2 "2024-08-05T17:17:22Z")

</div>

its crontrolled via CRDs

> <https://github.com/ansible/awx-operator/blob/devel/config/crd/bases/awx.ansible.com_awxbackups.yaml>

> <https://github.com/ansible/awx-operator/blob/devel/config/crd/bases/awx.ansible.com_awxrestores.yaml>

maybe look at:

> **[awx-on-k3s/backup at main · kurokobo/awx-on-k3s](https://github.com/kurokobo/awx-on-k3s/tree/main/backup)**
>
> An example implementation of AWX on single node K3s using AWX Operator, with easy-to-use simplified configuration with ownership of data and passwords. - kurokobo/awx-on-k3s

> **[awx-on-k3s/restore at main · kurokobo/awx-on-k3s](https://github.com/kurokobo/awx-on-k3s/tree/main/restore)**
>
> An example implementation of AWX on single node K3s using AWX Operator, with easy-to-use simplified configuration with ownership of data and passwords. - kurokobo/awx-on-k3s

---

<div class="post-metadata">

**Author:** ![jeremytourville](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jeremytourville/32/2448_2.png) [@jeremytourville](https://forum.ansible.com/u/jeremytourville)\
**Post date:** [August 6, 2024, 12:18pm UTC](https://forum.ansible.com/t/backup-posstgres-db-from-cluster-1-and-restore-db-to-cluster-2/7643/3 "2024-08-06T12:18:07Z")

</div>

Thank you for the links. I have read through everything and tried to understand as much as possible. I have my pv, pvc created for the backup. I applied the correct chown and chmod commands to the folders. I created backup manifest file like this:

```auto
---
apiVersion: awx.ansible.com/v1beta1
kind: AWXBackup
metadata:
  name: awxbackup-2024-08-06
  namespace: awx
spec:
  deployment_name: awx-operator-controller-manager

```

I then applied the manifest to my cluster. That went ok, no errors. I don’t see anything in my backup folder. When running Next steps to troubleshoot this?

---

<div class="post-metadata">

**Author:** ![Klaas](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@Klaas](https://forum.ansible.com/u/Klaas)\
**Post date:** [August 6, 2024, 3:05pm UTC](https://forum.ansible.com/t/backup-posstgres-db-from-cluster-1-and-restore-db-to-cluster-2/7643/4 "2024-08-06T15:05:36Z")

</div>

I think you need to defined backup\_pvc as well, and maybe also clean\_backup\_on\_delete

---

<div class="post-metadata">

**Author:** ![jeremytourville](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jeremytourville/32/2448_2.png) [@jeremytourville](https://forum.ansible.com/u/jeremytourville)\
**Post date:** [August 6, 2024, 5:13pm UTC](https://forum.ansible.com/t/backup-posstgres-db-from-cluster-1-and-restore-db-to-cluster-2/7643/5 "2024-08-06T17:13:30Z")

</div>

That is what was needed. I added those two extra parameters. Now the playbook completes with a failure.

```auto
PLAY RECAP *********************************************************************
localhost : ok=13 changed=1 unreachable=0 failed=1 skipped=8 rescued=0 ignored=0

----------
{"level":"error","ts":"2024-08-06T16:59:09Z","msg":"Reconciler error","controller":"awxbackup-controller","object":{"name":"awxbackup-08-05-2024","namespace":"awx"},"namespace":"awx","name":"awxbackup-08-05-2024","reconcileID":"746a5fdc-2c6d-4fef-9af0-71f4d4ba8722","error":"event runner on failed","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:274\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:235"}
{"level":"info","ts":"2024-08-06T16:59:10Z","logger":"logging_event_handler","msg":"[playbook debug]","name":"awxbackup-08-05-2024","namespace":"awx","gvk":"awx.ansible.com/v1beta1, Kind=AWXBackup","event_type":"runner_on_ok","job":"68433906028693526","EventData.TaskArgs":""}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 5, 2024, 5:13pm UTC](https://forum.ansible.com/t/backup-posstgres-db-from-cluster-1-and-restore-db-to-cluster-2/7643/6 "2024-09-05T17:13:41Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
