# Upgrade from 2.1.1 to latest 2.11.0 AWX-operator

**URL:** <https://forum.ansible.com/t/upgrade-from-2-1-1-to-latest-2-11-0-awx-operator/3855>\
**Category:** Get Help\
**Tags:** awx-operator, upgrade, migration, awx\
**Created:** [February 13, 2024, 6:41pm UTC](https://forum.ansible.com/t/upgrade-from-2-1-1-to-latest-2-11-0-awx-operator/3855 "2024-02-13T18:41:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mimianddaniel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mimianddaniel/32/2123_2.png) [@mimianddaniel](https://forum.ansible.com/u/mimianddaniel)\
**Post date:** [February 13, 2024, 6:41pm UTC](https://forum.ansible.com/t/upgrade-from-2-1-1-to-latest-2-11-0-awx-operator/3855/1 "2024-02-13T18:41:11Z")

</div>

Have external postgres setup using 2.1.1 AWX-operator, went through the changes in Awx-operator and awx change logs but didn’t see any mention of schema changes etc.

Noticed that there are some pending issues related to migrations where the migration is hanging:  
[https://github.com/ansible/awx-operator/issues/1673](https://github.com/ansible/awx-operator/issues/1673)

I will be following the migration steps:  
[awx-operator/docs/migration/migration.md at devel · ansible/awx-operator · GitHub](https://github.com/ansible/awx-operator/blob/devel/docs/migration/migration.md)

Any insight into or experience upgrading/migration would be very much appreciated.  
Obviously, I will be performing the work with the DB backup + K8 objects just in case.

Thanks

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@atul\_mohan](https://forum.ansible.com/u/atul_mohan)\
**Post date:** [January 5, 2025, 10:04pm UTC](https://forum.ansible.com/t/upgrade-from-2-1-1-to-latest-2-11-0-awx-operator/3855/2 "2025-01-05T22:04:43Z")

</div>

```auto
#!/bin/bash

# Variables
NAMESPACE="awx" # Change this to your AWX namespace
DB_USER="your_db_user" # Replace with your database user
DB_NAME="your_db_name" # Replace with your database name
DB_HOST="your_db_host" # Replace with your database host
DB_PORT="5432" # Replace with your database port if different
BACKUP_DATE=$(date +%Y%m%d)

# Backup your PostgreSQL Database
echo "Backing up PostgreSQL database..."
pg_dump -U $DB_USER -d $DB_NAME -h $DB_HOST -p $DB_PORT > /tmp/awx_backup_$BACKUP_DATE.sql

# Backup Kubernetes Resources
echo "Backing up Kubernetes resources..."
kubectl get all -n $NAMESPACE -o yaml > /tmp/awx_k8s_backup_$BACKUP_DATE.yaml

# Clone the latest AWX-operator repo
echo "Cloning AWX-operator repo..."
git clone --depth 1 --branch 2.11.0 https://github.com/ansible/awx-operator.git /tmp/awx-operator
cd /tmp/awx-operator

# Apply the new AWX-operator
echo "Applying new AWX-operator..."
kubectl apply -f deploy/operator.yml -n $NAMESPACE

# Wait for the operator to be deployed
echo "Waiting for AWX-operator deployment..."
kubectl rollout status deploy/awx-operator-controller-manager -n $NAMESPACE

# Update AWX Custom Resource (CR)
echo "Updating AWX Custom Resource..."
cat <<EOF | kubectl apply -f - -n $NAMESPACE
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx
spec:
  image: quay.io/ansible/awx:2.11.0
  postgres_configuration_secret: <your_secret_name> # Make sure this points to your external postgres config
EOF

# Monitor Migration
echo "Monitoring migration process..."
while true; do
    MIGRATION_POD=$(kubectl get pods -l job-name=awx-migrate -n $NAMESPACE -o jsonpath='{.items[0].metadata.name}')
    if [[-n $MIGRATION_POD]]; then
        kubectl logs $MIGRATION_POD -n $NAMESPACE
        if kubectl wait --for=condition=complete job/awx-migrate -n $NAMESPACE --timeout=300s; then
            echo "Migration completed."
            break
        else
            echo "Migration job is still running or has failed. Checking logs again..."
        fi
    else
        echo "No migration pod found yet..."
        sleep 10
    fi
done

# Manual Migration Step if Migration Hangs
echo "Checking for hanging migrations..."
MIGRATION_CHECK=$(kubectl exec -it $(kubectl get pods -l app=awx -n $NAMESPACE -o jsonpath='{.items[0].metadata.name}' -c awx-web) -c awx-web -n $NAMESPACE -- awx-manage showmigrations --list | grep -v '[X]' | grep '[]')
if [[-n $MIGRATION_CHECK]]; then
    echo "Pending migrations detected. Attempting manual migration..."
    kubectl exec -it $(kubectl get pods -l app=awx -n $NAMESPACE -o jsonpath='{.items[0].metadata.name}' -c awx-web) -c awx-web -n $NAMESPACE -- awx-manage migrate --noinput
else
    echo "No pending migrations."
fi

# Post-Upgrade Checks
echo "Checking AWX pods status..."
kubectl get pods -n $NAMESPACE

echo "Upgrade completed. Please manually verify AWX is functioning as expected."

```
