Introduction

The Ansible Automation Platform installer includes built-in backup and restore capabilities. A single setup.sh -b command creates a complete backup of the Automation Controller, Private Automation Hub, Event-Driven Ansible Controller, and the PostgreSQL database — everything you need to recover from failures or migrate to new infrastructure.

Prerequisites

  • Root access on the AAP installer host
  • The original setup.sh installer and inventory file
  • Sufficient disk space for the backup tarball
  • Same AAP version for backup and restore (version must match)

Backup Commands

Full Platform Backup

cd /path/to/ansible-automation-platform-setup-*/
sudo ./setup.sh -b

This creates a tarball in the current directory:

581M automation-platform-backup-2023-08-03-14:39:23.tar.gz

A symlink automation-platform-backup-latest always points to the most recent backup.

Backup to Custom Location

sudo ./setup.sh -e 'backup_dest=/backups/aap/' -b

What's Included in the Backup

ComponentData Backed Up
Automation ControllerJobs, inventories, credentials, projects, schedules, RBAC
Automation HubCollections, namespaces, container images, signing keys
EDA ControllerRulebooks, activations, event sources
PostgreSQLFull database dump
SECRET_KEYEncryption key for credentials
Custom configsManual projects, custom settings files

Restore Commands

Restore from Default Location

sudo ./setup.sh -r

This restores from the automation-platform-backup-latest symlink.

Restore from Specific Backup

sudo ./setup.sh -e 'restore_backup_file=/backups/aap/automation-platform-backup-2023-08-03-14:39:23.tar.gz' -r

Version Compatibility

RuleDetails
Same major.minor versionBackup from 2.4 must restore to 2.4
Latest patch recommendedUse the latest patch release for both backup and restore
PostgreSQL versionMust match the version supported by your AAP version

Check your version:

automation-controller-service --version

Automated Backup Schedule

Cron Job

# Daily backup at 2 AM
echo "0 2 * * * root cd /opt/aap-installer && ./setup.sh -e 'backup_dest=/backups/aap/' -b >> /var/log/aap-backup.log 2>&1" | sudo tee /etc/cron.d/aap-backup

Backup Rotation Script

#!/bin/bash
# /usr/local/bin/aap-backup-rotate.sh
BACKUP_DIR="/backups/aap"
KEEP_DAYS=30

# Run backup
cd /opt/aap-installer
./setup.sh -e "backup_dest=${BACKUP_DIR}/" -b

# Remove backups older than KEEP_DAYS
find "${BACKUP_DIR}" -name "automation-platform-backup-*.tar.gz" \
  -mtime +${KEEP_DAYS} -delete

echo "Backup completed. Removed files older than ${KEEP_DAYS} days."

Ansible Playbook for Backup

---
- name: Backup Ansible Automation Platform
  hosts: aap_installer
  become: true
  vars:
    aap_installer_dir: /opt/aap-installer
    backup_dest: /backups/aap
    retention_days: 30

  tasks:
    - name: Ensure backup directory exists
      ansible.builtin.file:
        path: "{{ backup_dest }}"
        state: directory
        mode: '0750'

    - name: Run AAP backup
      ansible.builtin.command:
        cmd: ./setup.sh -e "backup_dest={{ backup_dest }}/" -b
        chdir: "{{ aap_installer_dir }}"
      register: backup_result

    - name: Show backup result
      ansible.builtin.debug:
        msg: "{{ backup_result.stdout_lines | last }}"

    - name: Remove old backups
      ansible.builtin.find:
        paths: "{{ backup_dest }}"
        patterns: "automation-platform-backup-*.tar.gz"
        age: "{{ retention_days }}d"
      register: old_backups

    - name: Delete old backup files
      ansible.builtin.file:
        path: "{{ item.path }}"
        state: absent
      loop: "{{ old_backups.files }}"
      loop_control:
        label: "{{ item.path | basename }}"

Disaster Recovery Workflow

1. Fresh Install + Restore

# Install AAP on new infrastructure (same version)
cd /opt/aap-installer
./setup.sh

# Copy backup file to installer directory
cp /backups/aap/automation-platform-backup-2023-08-03-14:39:23.tar.gz .

# Restore
./setup.sh -e 'restore_backup_file=./automation-platform-backup-2023-08-03-14:39:23.tar.gz' -r

2. Verify After Restore

# Check services
automation-controller-service status

# Verify Controller API
curl -k https://controller.example.com/api/v2/ping/

# Verify Hub
curl -k https://hub.example.com/api/galaxy/v3/collections/

Clustered Environments

When backing up and restoring clustered AAP deployments:

ConsiderationDetails
Stop old cluster firstPrevent conflicts during restore
Per-node backupsRestore only to nodes with matching hostnames
Same inventory fileUse the same inventory that was used for installation
Manual projects preservedCustom projects carry over to new clusters

Cluster Restore

# Ensure old cluster is stopped
ansible all -i inventory -m shell -a "automation-controller-service stop"

# Restore on new cluster
./setup.sh -e 'restore_backup_file=/backups/latest.tar.gz' -r

Troubleshooting

Backup Fails with Disk Space Error

# Check available space
df -h /path/to/backup/

# Estimate backup size (roughly equal to database size)
sudo -u postgres pg_database_size awx

Restore Fails with Version Mismatch

ERROR: Backup version 2.3 does not match current version 2.4

Install the matching AAP version before restoring.

Database Connection Issues

# Verify PostgreSQL is running
systemctl status postgresql

# Check inventory database settings
grep pg_ inventory

Conclusion

setup.sh -b creates a complete AAP backup in a single command — Controller, Hub, EDA, database, and encryption keys. Schedule daily backups with cron, rotate old files with a retention policy, and test your restore process regularly. Always restore to the same AAP version, and keep the original inventory file alongside your backups — you'll need it for recovery.