# Migration of AWX objects between two installations

**URL:** <https://forum.ansible.com/t/migration-of-awx-objects-between-two-installations/29441>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [January 15, 2019, 9:52am UTC](https://forum.ansible.com/t/migration-of-awx-objects-between-two-installations/29441 "2019-01-15T09:52:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alberto\_Jimenez\_Loza](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@Alberto\_Jimenez\_Loza](https://forum.ansible.com/u/Alberto_Jimenez_Loza)\
**Post date:** [January 15, 2019, 9:52am UTC](https://forum.ansible.com/t/migration-of-awx-objects-between-two-installations/29441/1 "2019-01-15T09:52:58Z")

</div>

I have two awx installations.  
One AWX is the backup of main installation.

I have used tower-cli to do the export/import of the objetcts of the AWX.

EXPORT

tower-cli receive --all\> `date +%m.%d.%y_%H.%M.%S`\_assets\_awx.json

IMPORT

tower-cli send xxxxx.json

But this procedure doesn´t import

- Logs/history
- Credential passwords
- LDAP/AWX config

I find a project awx-migrate that makes a full backup of an AWX instance, and adds the secrets to the exported credentials, which tower-cli leaves empty.

[https://github.com/autops/awx-migrate](https://github.com/autops/awx-migrate)

I tried to install but when I execute the command awx-migrate-wrapper fails.

[root@ awx-migrate]# ./awx-migrate-wrapper  
Traceback (most recent call last):  
File “./awx-migrate”, line 16, in   
from cryptography.fernet import Fernet, InvalidToken  
ImportError: No module named cryptography.fernet

Has someone successfully used awx-migrate?

```auto

```

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [January 15, 2019, 9:58am UTC](https://forum.ansible.com/t/migration-of-awx-objects-between-two-installations/29441/2 "2019-01-15T09:58:52Z")

</div>

Hi Alberto,

I’m the author of the awx-migrate script.

The problem you encounter is due to not having the ndeed (Python) dependencies installed, which are documented in `Pipfile`:

- cryptography

- ansible-tower-cli

- psycopg2-binary

You can install them with the pipenv utility, or manually with pip, as you prefer.

HTH,

Serge

---

<div class="post-metadata">

**Author:** ![Alberto\_Jimenez\_Loza](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@Alberto\_Jimenez\_Loza](https://forum.ansible.com/u/Alberto_Jimenez_Loza)\
**Post date:** [January 15, 2019, 10:16am UTC](https://forum.ansible.com/t/migration-of-awx-objects-between-two-installations/29441/3 "2019-01-15T10:16:18Z")

</div>

I have installed the dependencies OK.

[root@V99SRH-003024 backup]# pip list|grep crypto  
cryptography 2.4.2  
[root@V99SRH-003024 backup]# pip list|grep psycopg2-binary  
psycopg2-binary 2.7.6.1

My inventory installation is:

[root@xxx installer]# cat inventory |grep -v “#”  
localhost ansible\_connection=local ansible\_python\_interpreter=“/usr/bin/env python”  
[all:vars]

dockerhub\_base=ansible

dockerhub\_version=latest  
postgres\_data\_dir=/srv/pgdocker

host\_port=80  
use\_docker\_compose=True

docker\_compose\_dir=/var/lib/awx  
docker\_remove\_local\_images=True

pg\_username=awx

pg\_password=awxpass  
pg\_database=awx  
pg\_port=5432  
default\_admin\_user=admin

default\_admin\_password=admin32awx  
secret\_key=awxsecret

project\_data\_dir=/var/lib/awx/projects

I have a awx installation with dockers.

docker ps  
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
9c36aaabc14a ansible/awx\_task:latest “/tini – /bin/sh …” 3 months ago Up 6 weeks 8052/tcp awx\_task\_1  
a6881a17b80f ansible/awx\_web:latest “/tini – /bin/sh …” 3 months ago Up 6 weeks 0.0.0.0:80-\>8052/tcp awx\_web\_1  
e224fd865187 postgres:9.6 “docker-entrypoint…” 3 months ago Up 6 weeks 5432/tcp awx\_postgres\_1  
4e9d3980e4b2 ansible/awx\_rabbitmq:3.7.4 “docker-entrypoint…” 3 months ago Up 6 weeks 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp awx\_rabbitmq\_1  
c2a41c882e0c memcached:alpine “docker-entrypoint…” 3 months ago Up 6 weeks 11211/tcp awx\_memcached\_1

When I edit edit `awx-migrate-wrapper` and set the right `AWX_SRC_*` and `AWX_DST_*, I have a doubt.`  
`What do I put in export AWX_SRC_DBHOST?`

`If I put localhost, it fails. What is the value of `AWX\_SRC\_DBHOST in a AWX with dockers?

`  
[root@V99SRH-003024 awx-migrate]# ./awx-migrate-wrapper  
I am unable to connect to source database:

could not connect to server: Connection refused  
Is the server running on host “localhost” (127.0.0.1) and accepting  
TCP/IP connections on port 5432?

[root@V99SRH-003024 awx-migrate]#  
`

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [January 15, 2019, 10:30am UTC](https://forum.ansible.com/t/migration-of-awx-objects-between-two-installations/29441/4 "2019-01-15T10:30:42Z")

</div>

> I have a awx installation with dockers.
> 
> docker ps  
> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
> 9c36aaabc14a ansible/awx\_task:latest “/tini – /bin/sh …” 3 months ago Up 6 weeks 8052/tcp awx\_task\_1  
> a6881a17b80f ansible/awx\_web:latest “/tini – /bin/sh …” 3 months ago Up 6 weeks 0.0.0.0:80-\>8052/tcp awx\_web\_1  
> e224fd865187 postgres:9.6 “docker-entrypoint…” 3 months ago Up 6 weeks 5432/tcp awx\_postgres\_1  
> 4e9d3980e4b2 ansible/awx\_rabbitmq:3.7.4 “docker-entrypoint…” 3 months ago Up 6 weeks 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp awx\_rabbitmq\_1  
> c2a41c882e0c memcached:alpine “docker-entrypoint…” 3 months ago Up 6 weeks 11211/tcp awx\_memcached\_1
> 
> When I edit edit `awx-migrate-wrapper` and set the right `AWX_SRC_*` and `AWX_DST_*, I have a doubt.`  
> `What do I put in export AWX_SRC_DBHOST?`

SRC is the source database, the old instance  
DST is the new one  
so the script would migrate configs and ldap settings FROM the old db TO the new db.  
I see you only have one postgresql running?

> `If I put localhost, it fails. What is the value of `AWX\_SRC\_DBHOST in a AWX with dockers?

That depends on how you make the docker port available on your host machine, or where-ever you run this script from.  
That is more a docker specific issue though.

Have a look at the docker run --publish option.

Serge

---

<div class="post-metadata">

**Author:** ![Alberto\_Jimenez\_Loza](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@Alberto\_Jimenez\_Loza](https://forum.ansible.com/u/Alberto_Jimenez_Loza)\
**Post date:** [January 15, 2019, 12:19pm UTC](https://forum.ansible.com/t/migration-of-awx-objects-between-two-installations/29441/5 "2019-01-15T12:19:26Z")

</div>

I have the standard installation of AWX.

The host where are running the dockers has this ports listened and I want to execute awx-migrate-wrapper in this server.

[root@docker awx-migrate]# netstat -nap|grep -i listen|grep -vi listening  
tcp 0 0 127.0.0.1:25 0.0.0.0:\* LISTEN 1564/master  
tcp 0 0 0.0.0.0:80 0.0.0.0:\* LISTEN 54596/docker-proxy-  
tcp 0 0 0.0.0.0:22 0.0.0.0:\* LISTEN 79846/sshd  
tcp 0 0 0.0.0.0:4118 0.0.0.0:\* LISTEN 1394/ds\_agent

Postgres BD is running in one docker in the port 5432.

e224fd865187 postgres:9.6 “docker-entrypoint…” 3 months ago Up 6 weeks 5432/tcp awx\_postgres\_1

I have to publish the docker port 5432 to the host?  
How do I configure that?

---

<div class="post-metadata">

**Author:** ![Alberto\_Jimenez\_Loza](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@Alberto\_Jimenez\_Loza](https://forum.ansible.com/u/Alberto_Jimenez_Loza)\
**Post date:** [January 21, 2019, 7:56am UTC](https://forum.ansible.com/t/migration-of-awx-objects-between-two-installations/29441/6 "2019-01-21T07:56:33Z")

</div>

I try a fast solution, but I think that isn´t the most optimal.

I have created a new docker with socat to make accesible make the docker port available.

docker ps  
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
e13e5dcfdbdb alpine/socat “socat tcp-listen:…” 3 days ago Up 3 days 0.0.0.0:5432-\>5432/tcp modest\_fermi

Awx-migrate works ok.

./awx-migrate-wrapper

Wrong encryption key for config field AUTH\_LDAP\_BIND\_PASSWORD, you will need to update this manually.

AWX settings where migarted, except passwords. Update those manually: E.g.:

# tower-cli setting set AUTH\_LDAP\_BIND\_PASSWORD ‘53cr37’

To restore, run:

tower-cli send awx-data.json

Or, restore only specific objects, or in paritcular order with one of:

tower-cli send awx-data-user.json

tower-cli send awx-data-organization.json

tower-cli send awx-data-team.json

tower-cli send awx-data-credential\_type.json

tower-cli send awx-data-credential.json

tower-cli send awx-data-notification\_template.json

tower-cli send awx-data-inventory\_script.json

tower-cli send awx-data-project.json

tower-cli send awx-data-inventory.json

tower-cli send awx-data-job\_template.json

tower-cli send awx-data-workflow.j

Also filtering content of dynamic inventories (with sources) into \_filtered.json files.
