How to restore Templates and Projects ?

Hi!

Unfortunately, I ran into problem with upgrading awx to 1.0.7. I had tried to update existing awx. Now my instance doesn’t work. Than I made a dump of awx database, made fresh install and imported it. Now I can login to my instance and all my settings exist here except Templates and Projects. I use docker installation method with external project_data_dir so my projects are present in container. Is there any way to restore them into awx?

P.S. I’ve tried to get objects via tower-cli but without any luck.

Hello Kan,

AWX does not provide any integrated solution to perform backup and restore and therefore the upgrades and migrations can only be performed as a fresh installation. In AWX there does exist a workaround, which involves copying the PostgreSQL data directory and using the same with a fresh installation to restore the backup.

In order to implement the workaround we need to perform following steps:

  1. Stop the PostgreSQL docker container and copy the content of /var/lib/pgdocker directory on awx node to the same directory on awx-2 node:
    $ docker stop <container_id>
    $ scp -r ./pgdocker awx-2:/var/lib/

  2. Edit inventory file in installer directory on awx-2 node and provide the location of pgdocker directory in postgres_data_dir variable:
    Set value of “postgres_data_dir” in inventory file
    $ vi inventory
    postgres_data_dir = </var/lib/pgdocker>

  3. Install AWX as a fresh installation in awx-2 node using the modified inventory file:
    $ ansible-playbook -i inventory install.yml –vv

  4. The backed up content of awx will be visible on awx-2 dashboard.

Thanks
Soniya

Are you sure this will work if the versions are different for both AWX setups?

If I am not mistaken the preferred way to upgrade is to use tower-cli to do an export. Wipe the containers. Reinstall the containers and then reimport through tower-cli. Note credentials and job history is not backed up.

The reason why this is because the team may make sudden changes to database tables and such. Exporting through towsr-cli allows you to preserve this albiet those two things.

Hello Wei-Yen Tan,

Yes, there are two options available to perform data migration from the old AWX instance to the new upgraded AWX instance:

  1. Making use of tower-cli send/receive feature as described in following link: https://github.com/ansible/awx/blob/devel/DATA_MIGRATION.md . Please note, this option would not migrate system settings, scheduled jobs and permissions. These are to be migrated manually.
  2. Taking a backup of the directory where the PostgreSQL DB is stored and doing a fresh installation after setting postgres_data_dir parameter in inventory file. However, please note this option would not perform the backup of venv variables and configuration files of AWX.

Thanks
Soniya