How we restored our data in AWX after upgrading
This is what I did after upgrading from version 2 to version 17 and all the configuration was lost. Paths in this tutorial might be different for you, depending on your configuration. This might also be a bit sketchy, but hopefully it can give you some ideas on how to continue to fix your installation.
Based on what I have read: You need to have the same secrets configured in your old and new inventory when running the installation playbook, otherwise the encrypted credentials cannot be opened.
Basic procedure
- old database A (with your data) in directory a
- new database B (empty) in directory b
- dump A to some path
- rename B to free its name for the next step
- restore A with the old name of B in location b
- awx-manage migrate in the awx_task docker container
Figuring out where the data is and verifying that it is not migrated
lists your containers. There were two postgres containers:
There is the "awx" database. You can for example find users via
SELECT * FROM auth_user;
which was empty for me except for the admin.
From an older version there is also a container called "postgres".
Doing the same thing in there yields all of my old data. But
that database is outdated and some columns are therefore missing, like
After looking around, I found a Migration to add the column of the example: https://github.com/ansible/awx/blob/devel/awx/main/migrations/0120_galaxy_credentials.py, so I wanted to now figure out a way to run this and all other migrations.
Going back to the host machine (out of the docker bash) via Ctrl + D, you should check the path in your inventory file (cloned from the repo) or vars.yml (if you use one) that leads to the postgres data:
Is it correct? If not you might have also screwed up your upgrade procedure. If you use vars.yml for the installation the setting there takes priority over the inventory file.
Turned out in /var/lib/awx/pgdocker there are two postgres data locations:
You might just compare the timestamps of those files to figure out which directory contains your database with your data.
Migrating the old data
I created a dump of the old databse and moved it to the directory of the new container (so that it is accessible from a bash in there). Depending on your container and path setup paths might be different!
the dump should now be in the postgres_data_dir on the host.
but you can put it anywhere if that doesn't work for you
and use
In the new container restore that dump (Also see https://www.postgresqltutorial.com/postgresql-rename-database/)
The new container now contains the old data, but in an outdated database format. The migrations need to be executed.
Since the connections to the db have been closed manually previously, I restart the docker service which restarts AWX.
sudo systemctl restart docker
I then was able to log in into the new version with my old account.