# Automatic Backup (with official role)

**URL:** <https://forum.ansible.com/t/automatic-backup-with-official-role/37347>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [November 14, 2022, 8:22pm UTC](https://forum.ansible.com/t/automatic-backup-with-official-role/37347 "2022-11-14T20:22:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Macle](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@Anthony\_Macle](https://forum.ansible.com/u/Anthony_Macle)\
**Post date:** [November 14, 2022, 8:22pm UTC](https://forum.ansible.com/t/automatic-backup-with-official-role/37347/1 "2022-11-14T20:22:47Z")

</div>

Hello,

How could I automatically run daily backup using the role ?  
I dont think it is possible to use cronjob object with role ?

Once the awxbackup.yml is executed, the backup works fine, however an object “awxbackup” is created and stays alive in the cluster.  
Can someone explain me why this object stays in the cluster since the backup in only executed once when the yaml manifest is applied ?

Here is the official role i am using.  
[https://github.com/ansible/awx-operator/tree/devel/roles/backup](https://github.com/ansible/awx-operator/tree/devel/roles/backup)

Any help would much appreciated

---

<div class="post-metadata">

**Author:** ![kurokobo1](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@kurokobo1](https://forum.ansible.com/u/kurokobo1)\
**Post date:** [November 14, 2022, 9:05pm UTC](https://forum.ansible.com/t/automatic-backup-with-official-role/37347/2 "2022-11-14T21:05:02Z")

</div>

Hi,

> How could I automatically run daily backup using the role ?  
> I dont think it is possible to use cronjob object with role ?

There is no official guide, but technically daily backup can be achieved by some way e.g.:

- Create playbook to take backup and register it as scheduled job on your AWX

# F.Y.I., this is my example implementation: [https://github.com/kurokobo/awx-on-k3s/tree/main/backup/ansible](https://github.com/kurokobo/awx-on-k3s/tree/main/backup/ansible)

- Create cronjob on your K8s that run playbook or just apply awxbackup.yml to your cluster.

> Can someone explain me why this object stays in the cluster since the backup in only executed once when the yaml manifest is applied ?

The AWXBackup can easily be used to restore AWX via “backup\_name” for AWXRestore.  
[https://github.com/ansible/awx-operator/tree/devel/roles/restore](https://github.com/ansible/awx-operator/tree/devel/roles/restore)  
In addition, you can configure AWXBackup so that when it is deleted, the backup data on the PVC is also deleted via “clean\_backup\_on\_delete: true”. So the presence of AWXBackup resources can be used to manage backup generations

Regards,

---

<div class="post-metadata">

**Author:** ![Anthony\_Macle](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@Anthony\_Macle](https://forum.ansible.com/u/Anthony_Macle)\
**Post date:** [November 14, 2022, 9:21pm UTC](https://forum.ansible.com/t/automatic-backup-with-official-role/37347/3 "2022-11-14T21:21:20Z")

</div>

@kurokobo

Thanks a for your reply.

I forgot to mention that I am using minikube. do you think the playbook method is still an option?

Regards,

-------- Message original --------

---

<div class="post-metadata">

**Author:** ![kurokobo1](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@kurokobo1](https://forum.ansible.com/u/kurokobo1)\
**Post date:** [November 15, 2022, 6:25am UTC](https://forum.ansible.com/t/automatic-backup-with-official-role/37347/4 "2022-11-15T06:25:36Z")

</div>

Hi,

> do you think the playbook method is still an option?

I believe yes, you should try it out 🙂  
Please be careful not to accidentally delete PV and PVC that includes backup data, as the playbook does not include tasks to retrieve data stored in PVs on minikube.

Regards,
