# Recovering lost data

**URL:** <https://forum.ansible.com/t/recovering-lost-data/30483>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [June 4, 2019, 5:13am UTC](https://forum.ansible.com/t/recovering-lost-data/30483 "2019-06-04T05:13:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pranjal\_Gupta](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Pranjal\_Gupta](https://forum.ansible.com/u/Pranjal_Gupta)\
**Post date:** [June 4, 2019, 5:13am UTC](https://forum.ansible.com/t/recovering-lost-data/30483/1 "2019-06-04T05:13:00Z")

</div>

hiii,

Is there any way to take snapshot of awx at regular interval so that we could recover the data if something goes wrong in future !!

---

<div class="post-metadata">

**Author:** ![Sujith\_A\_R1](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sujith\_A\_R1](https://forum.ansible.com/u/Sujith_A_R1)\
**Post date:** [June 4, 2019, 5:50am UTC](https://forum.ansible.com/t/recovering-lost-data/30483/2 "2019-06-04T05:50:54Z")

</div>

Backup the DB which is postgre contents on regular intervals

---

<div class="post-metadata">

**Author:** ![Pranjal\_Gupta](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Pranjal\_Gupta](https://forum.ansible.com/u/Pranjal_Gupta)\
**Post date:** [June 4, 2019, 6:38am UTC](https://forum.ansible.com/t/recovering-lost-data/30483/3 "2019-06-04T06:38:25Z")

</div>

I guess this is hack kind of thing and not the proper solution. Although it worked.  
But is there a more organised way somewhat like taking screenshot of all 5 docker container, so that if anything goes wrong in future other than data too , I could have my awx up and running again.

---

<div class="post-metadata">

**Author:** ![Sujith\_A\_R1](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sujith\_A\_R1](https://forum.ansible.com/u/Sujith_A_R1)\
**Post date:** [June 4, 2019, 6:47am UTC](https://forum.ansible.com/t/recovering-lost-data/30483/4 "2019-06-04T06:47:37Z")

</div>

If you wish to scale the AWX in HA mode , then you can refer this link [https://github.com/ansible/awx/issues/3627](https://github.com/ansible/awx/issues/3627) , so even if one is down , you can scale to next.

Also note that, these containers can be killed at anytime , we need to only look for the DB contents when it comes to backup without worrying about the container state.

Regards,  
Sujith

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [June 4, 2019, 12:01pm UTC](https://forum.ansible.com/t/recovering-lost-data/30483/5 "2019-06-04T12:01:48Z")

</div>

Making a backup of the database is not a “hack kind of thing”. You should already be setting up streaming replication on postgres as part of your normal operation. You can take snapshots of this replica and can even promote it to primary if it goes down. The docker containers for AWX are mostly transient and all state is store in the database. Therefore, that’s what you need to focus your backup and recovery strategy on.

---

<div class="post-metadata">

**Author:** ![Pranjal\_Gupta](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Pranjal\_Gupta](https://forum.ansible.com/u/Pranjal_Gupta)\
**Post date:** [June 4, 2019, 12:51pm UTC](https://forum.ansible.com/t/recovering-lost-data/30483/6 "2019-06-04T12:51:27Z")

</div>

pardon me for asking such immature doubts but I am new to all this. All kind of help is heartly welcomed.

So by backing up postgre you mean copying the folder pgdata which is located inside pgdocker in some backup. Let me know if this is what you meant.

Regards,  
Pranjal

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [June 4, 2019, 1:38pm UTC](https://forum.ansible.com/t/recovering-lost-data/30483/7 "2019-06-04T13:38:21Z")

</div>

You have a lot of reading to do in order to set this up as a production system, start here:

[https://www.postgresql.org/docs/9.6/backup.html](https://www.postgresql.org/docs/9.6/backup.html)

also see:

[https://wiki.postgresql.org/wiki/Streaming\_Replication](https://wiki.postgresql.org/wiki/Streaming_Replication)

---

<div class="post-metadata">

**Author:** ![klaasdemter](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@klaasdemter](https://forum.ansible.com/u/klaasdemter)\
**Post date:** [June 4, 2019, 7:16pm UTC](https://forum.ansible.com/t/recovering-lost-data/30483/8 "2019-06-04T19:16:38Z")

</div>

if you're using a kubernetes/openshift install there are tasks for backup/restore  
[https://github.com/ansible/awx/blob/devel/installer/roles/kubernetes/tasks/backup.yml](https://github.com/ansible/awx/blob/devel/installer/roles/kubernetes/tasks/backup.yml)  
[https://github.com/ansible/awx/blob/devel/installer/roles/kubernetes/tasks/restore.yml](https://github.com/ansible/awx/blob/devel/installer/roles/kubernetes/tasks/restore.yml)  
but sadly you'll need to make your own container see [https://github.com/ansible/awx/pull/2831](https://github.com/ansible/awx/pull/2831)

---

<div class="post-metadata">

**Author:** ![Pranjal\_Gupta](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Pranjal\_Gupta](https://forum.ansible.com/u/Pranjal_Gupta)\
**Post date:** [June 5, 2019, 8:07am UTC](https://forum.ansible.com/t/recovering-lost-data/30483/9 "2019-06-05T08:07:25Z")

</div>

Thanks man… This will help me a lot.  
You all are doing a great work !!

---

<div class="post-metadata">

**Author:** ![Pranjal\_Gupta](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Pranjal\_Gupta](https://forum.ansible.com/u/Pranjal_Gupta)\
**Post date:** [June 5, 2019, 8:25pm UTC](https://forum.ansible.com/t/recovering-lost-data/30483/10 "2019-06-05T20:25:23Z")

</div>

I went through the documents you mentioned.  
I only have very little knowledge about docker so pardon me if I say anything silly.

1. [Talking about first technique — pg\_dumpall]  
As per what I understand, postgre docker is running in detached mode and has mounted the memory var/lib/postgre/data to the path tmp/awx/pgdocker/pgdata . let me know if it is not the case.  
So to execute anything like pg\_dumpall what I did is, I entered the container and created a recovery file using pg\_dumpall and moved that file to the location which is common to main os and docker.  
By by this if anything goes wrong, I could use this file back. I tried this and it worked(obviously). Now what I think is , I am doing something wrong here. Please let me know how should I have done it.

2. [talking about second technique – file system level backup]  
what I learned is that for that you need to shut the server down first but the problem is as soon as I shut the server (by going in container and executing pg\_ctl stop), it shuts and starts immediately. Let me know what I should have done instead.

Let me know which technique I should be using

Also one more thing

1. can we use sql instead of postgre.

---

<div class="post-metadata">

**Author:** ![Pranjal\_Gupta](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@Pranjal\_Gupta](https://forum.ansible.com/u/Pranjal_Gupta)\
**Post date:** [June 6, 2019, 6:54am UTC](https://forum.ansible.com/t/recovering-lost-data/30483/11 "2019-06-06T06:54:41Z")

</div>

Guys waiting for your reply. Please help me out

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [June 6, 2019, 11:43am UTC](https://forum.ansible.com/t/recovering-lost-data/30483/12 "2019-06-06T11:43:11Z")

</div>

postgresql is sql
