AWX V19 - Backup and Restore

3,028 views
Skip to first unread message

vanda...@gmail.com

unread,
Jul 23, 2021, 9:07:21 AM7/23/21
to AWX Project
AWX V19 - Backup and  Restore.
Hello experts, I have  setup AWX v19 following  this 

Not sure how to perform the backup and  restore  of  AWX v19 .
i  tried below  steps:

1. Export Docker DB like: pg_dump --username awx awx --format=c" > ./psql_dump.sql
2. Drop AWX-Operator DB: minikube kubectl -- exec -it awx-postgres-0 -- dropdb -U awx awx ( failed here since  the db was  currently  being  used)

3. Create new DB: minikube kubectl -- exec -it awx-postgres-0 -- createdb -U awx awx
4. Restore DB: minikube kubectl -- exec -it awx-postgres-0 -- pg_restore -U awx -d awx < psql_dump.sql

BR//
Vandana Thakur



Christian Adams

unread,
Jul 23, 2021, 9:23:59 AM7/23/21
to vanda...@gmail.com, AWX Project
Hi Vandana,

It sounds like you have AWX installed via the awx-operator in minikube.  You can use the backup and restore roles in the awx-operator to accomplish this.  

At a high level, you create a AWXBackup CR (custom resource) object in your minikube cluster, which runs the backup role.  This will back up your deployment's AWX object, Postgresql database, and secrets into a persistent volume claim in your cluster.  This can then be restored to a new deployment by creating a AWXRestore object referencing your backup.  

Sidenote, in your approach, you would need to stop the application containers before dropping the database to avoid the error you are running into.  

Thanks,
Christian

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/d30a66b7-c14d-4a7a-94d1-d7fe60b6af7bn%40googlegroups.com.


--
__________________________________________________
Christian M. Adams
Software Engineer at Ansible - Red Hat
cha...@redhat.com  |  (919) 218-5080  |  GitHub: rooftopcellist

The Vandyy Vines

unread,
Aug 2, 2021, 9:20:13 AM8/2/21
to Christian Adams, AWX Project
So, I added a CRD for backup and  applied as a pod.

[test@k8s]$   k  get  po -A
NAMESPACE       NAME                                        READY   STATUS      RESTARTS   AGE
default         awx-demo-7d5777dcd6-c6nxk                   4/4     Running     0          5d23h
default         awx-demo-postgres-0                         1/1     Running     0          7d
default         awx-operator-5dd757f594-c2snd               1/1     Running     5          7d
default         awxbackup-2021-07-27-db-management          1/1     Running     0          30s
ingress-nginx   ingress-nginx-admission-create-4mb4x        0/1     Completed   0          7d

All pods are running  and I can access th eAWX GUI ,but  unfortunately  I can't  see the PVC in Output.

[test@k8s]$ k  get awxbackup awxbackup-2021-07-27 -o jsonpath="{.items[0].status.backupDirectory}" 
[test@k8s]$ docker exec -it 6b87ee77cebc /bin/bash
root@awxbackup-2021-07-27-db-management:/#   cd  /backups/
root@awxbackup-2021-07-27-db-management:/backups#   ls
root@awxbackup-2021-07-27-db-management:/backups#


BR//
Vandana

Christian Adams

unread,
Aug 2, 2021, 9:36:18 AM8/2/21
to The Vandyy Vines, AWX Project
Adding AWX Project group back to thread to provide other's context/info.  

Thanks,
Christian

On Mon, Aug 2, 2021 at 9:35 AM Christian Adams <cha...@redhat.com> wrote:
You can create backup & restore custom resources from any operating system that you can install the kubectl or oc tools on.  

It sounds like there may have been an error with the backup.  You can check for errors in the `awx-operator` pod's logs.  It might also be useful to look at the yaml for that backup object to see if there are any errors on it, or useful statuses.  

`kubectl get awxbackup awxbackup-2021-07-27 -o yaml`

Thanks,
Christian

The Vandyy Vines

unread,
Aug 2, 2021, 9:56:04 AM8/2/21
to Christian Adams, AWX Project
Yes there is an error.. But cant see any errors in operator logs.

name: awxbackup-2021-07-27
namespace: default
spec:
  deployment_name: awx-demo
status:
  conditions:
  - ansibleResult:
      changed: 2
      completion: 2021-08-02T13:52:10.856248
      failures: 1
      ok: 14
      skipped: 6
    lastTransitionTime: "2021-08-02T13:52:11Z"
    message: unknown playbook failure
    reason: Failed
    status: "False"
    type: Failure
  - lastTransitionTime: "2021-08-02T13:52:12Z"
    message: Running reconciliation
    reason: Running
    status: "True"
    type: Running
[test@vuhplabgtdbg001 ~]$

The Vandyy Vines

unread,
Aug 3, 2021, 6:49:20 AM8/3/21
to Christian Adams, AWX Project
Hello Experts ,

I searched a lot on the issue i am facing, Got a related discussion.

image.png

=====logs

Once I manually change awx-operator deployment to use quay.io/ansible/awx-operator:devel I have PVC awx-backup-claim created. I have pod awxbackup-db-management created and mounted this PV awx-backup-claim, but folder backups inside pod awxbackup-db-management is empty, and no backups created.

I also created a new backup with:

---
apiVersion: awx.ansible.com/v1beta1
kind: AWXBackup
metadata:
  name: awxbackup2
  namespace: default
spec:
  deployment_name: awx

But still no backup created.

And this is the status of this awxbackup2

status:                                                                                                                                                                                       │
│   conditions:                                                                                                                                                                                 │
│   - lastTransitionTime: "2021-05-20T13:58:25Z"                                                                                                                                                │
│     message: Running reconciliation                                                                                                                                                           │
│     reason: Running                                                                                                                                                                           │
│     status: "False"                                                                                                                                                                           │
│     type: Running                                                                                                                                                                             │
│   - ansibleResult:                                                                                                                                                                            │
│       changed: 3                                                                                                                                                                              │
│       completion: 2021-05-20T14:04:40.55262                                                                                                                                                   │
│       failures: 1                                                                                                                                                                             │
│       ok: 14                                                                                                                                                                                  │
│       skipped: 6                                                                                                                                                                              │
│     lastTransitionTime: "2021-05-20T14:04:40Z"                                                                                                                                                │
│     message: unknown playbook failure                                                                                                                                                         │
│     reason: Failed                                                                                                                                                                            │
│     status: "True"                                                                                                                                                                            │
│     type: Failure


Exactly the same issue that I am facing.
Can someone help here?

BR//

The Vandyy Vines

unread,
Aug 3, 2021, 10:17:12 AM8/3/21
to Christian Adams, AWX Project
I managed to perform the backup ( not sure its correct)
But restoration is still failing  with:

==
image.png
Where in backup Role i can see the variable  :
image.png
and  the  variable:
image.png
But in Restoration the  variable  asked is  database_type  which  fails as it is  undefined.Hence restoration is failing.

Can anyone help here ?


agenttank

unread,
Sep 14, 2021, 5:55:24 AM9/14/21
to AWX Project
hi!
why does nobody seem to know how to backup and restore this overcomplicated awx/awx-operator on kubernetes-thing!?
this is needed!

HG

unread,
Jul 21, 2022, 5:46:00 AM7/21/22
to AWX Project
Hello all,

Anyone to help on this issue??
I have the same.

Regards Hans-Peter

Op dinsdag 14 september 2021 om 11:55:24 UTC+2 schreef s.pin...@gmail.com:

AWX Project

unread,
Jul 27, 2022, 4:31:35 PM7/27/22
to AWX Project

Vandana,

The restore role had a bug causing it to not be compatible with external databases. The fix has been merged here - https://github.com/ansible/awx-operator/pull/877

If you still have your backup, you could try restoring with the an awx-operator built from the devel branch.  The fix will be available in the next AWX release.

Thanks,
AWX Team
Reply all
Reply to author
Forward
0 new messages