The AWX Operator 0.10.0
or later has the ability to restore AWX in easy way.
This guide is specifically designed to use with the AWX which deployed using the main guide on this repository.
You can also refer the official instructions for more information.
To perform restoration, you need to have AWX Operator running on Kubernetes. If you are planning to restore to a new environment, first prepare Kubernetes and AWX Operator by referring to the instructions on the main guide.
It is strongly recommended that the version of AWX Operator is the same as the version when the backup was taken. This is because the structure of the backup files differs between versions and may not be compatible. If you have upgraded AWX Operator after taking the backup, it is recommended to downgrade AWX Operator first before performing the restore. To deploy 0.13.0
or earlier version of AWX Operator, refer 📝Tips: Deploy older version of AWX Operator
Some manual additions, such as the HSTS configuration or similar tips will not be restored automatically, and will have to be reapplied after restoring. AWX may not be fully functional depending on the missing manual additions after restoring.
If your AWX instance is running, it is recommended that it be deleted along with PVC and PV for the PostgreSQL first, in order to restore to be succeeded.
# Delete AWX resource, PVC, and PV
kubectl -n awx delete pvc postgres-15-awx-postgres-15-0 --wait=false
kubectl -n awx delete awx awx
kubectl delete pv awx-postgres-15-volume
# Delete any data in the PV
sudo rm -rf /data/postgres-15
Then prepare directories for your PVs. /data/projects
is required if you are restoring the entire AWX to a new environment.
sudo mkdir -p /data/postgres-15/data
sudo chown 26:0 /data/postgres-15/data
sudo chmod 700 /data/postgres-15/data
sudo mkdir -p /data/projects
sudo chown 1000:0 /data/projects
Then deploy PV and PVC. It is recommended that making the size of PVs and PVCs same as the PVs which your AWX used when the backup was taken.
kubectl apply -k restore
Modify the name of the AWXRestore object in restore/awxrestore.yaml
.
...
kind: AWXRestore
metadata:
name: awxrestore-2021-06-06 👈👈👈
namespace: awx
...
If you want to restore from AWXBackup object, specify its name in restore/awxrestore.yaml
.
...
# Parameters to restore from AWXBackup object
backup_name: awxbackup-2021-06-06 👈👈👈
...
If the AWXBackup object no longer exists, place the backup files under /data/backup/<backup directory>
(e.g. /data/backup/tower-openshift-backup-2021-06-06-105149
) and specify the name of the PVC and directory in restore/awxrestore.yaml
.
...
# Parameters to restore from existing files on PVC (without AWXBackup object)
backup_pvc: awx-backup-claim 👈👈👈
backup_dir: /backups/tower-openshift-backup-2021-06-06-105149 👈👈👈
...
Then invoke restore by applying this manifest file.
kubectl apply -f restore/awxrestore.yaml
To monitor the progress of the deployment, check the logs of deployments/awx-operator-controller-manager
:
kubectl -n awx logs -f deployments/awx-operator-controller-manager
When the restore complete successfully, the logs end with:
$ kubectl -n awx logs -f deployments/awx-operator-controller-manager
...
----- Ansible Task Status Event StdOut (awx.ansible.com/v1beta1, Kind=AWX, awx/awx) -----
PLAY RECAP *********************************************************************
localhost : ok=92 changed=0 unreachable=0 failed=0 skipped=81 rescued=0 ignored=1
This will create AWXRestore object in the namespace, and now your AWX is restored.
$ kubectl -n awx get awxrestore
NAME AGE
awxrestore-2021-06-06 137m