Skip to main content

Overview

AWX stores critical data in PostgreSQL and configuration settings in the database and file system. Regular backups ensure you can recover from system failures, migrate to new infrastructure, or rollback problematic changes.
Always test your backup and restore procedures in a non-production environment before relying on them for disaster recovery.

Database Backups

PostgreSQL Direct Backup

AWX uses PostgreSQL to store all persistent data including job history, credentials (encrypted), inventory, and configuration settings.

Full Database Backup

Use pg_dump to create a complete backup of the AWX database:
Backup options:
  • -F c — Custom format (compressed, supports selective restore)
  • -F p — Plain SQL format (human-readable)
  • -F t — Tar format
Use custom format (-F c) for production backups. It provides compression and allows selective restoration of specific tables.

Scheduled Backups

Create a cron job for automated daily backups:
This configuration:
  • Runs daily at 2:00 AM
  • Creates compressed backups
  • Automatically removes backups older than 30 days

Kubernetes PostgreSQL Backup

For AWX deployed in Kubernetes with an external PostgreSQL database:

Restoring Database Backups

Restore from Custom Format

Restore options:
  • -c — Clean (drop) database objects before recreating
  • -C — Create the database before restoring
  • --if-exists — Use with -c to suppress errors if objects don’t exist

Restore from SQL Format

Restoring a backup will overwrite all existing data in the target database. Always verify you’re restoring to the correct database.

AWX Operator Backup

The AWX Operator provides built-in backup and restore capabilities for Kubernetes-based deployments.

Creating Operator Backups

Define an AWXBackup custom resource:
awx-backup.yaml
Apply the backup:
Check backup status:

Scheduled Operator Backups

Create a CronJob for automated backups:
awx-backup-cronjob.yaml

Restoring from Operator Backup

Define an AWXRestore custom resource:
awx-restore.yaml
Apply the restore:
Monitor restore progress:
The AWX Operator backup includes the database dump, secret keys, and configuration. The restore process automatically handles database restoration and secret key configuration.

Configuration Backup

AWX configuration includes settings stored in the database and file-based settings.

Exporting Settings via API

Export all configuration settings:

File-Based Configuration

Backup custom configuration files from /etc/tower/conf.d/:

Restoring Configuration

Restore settings via the API:
Encrypted settings (like external service tokens) may not be directly restorable. You may need to re-enter sensitive values after restoration.

Secret Key Management

The SECRET_KEY is critical for encrypting sensitive data. Losing it makes encrypted credentials unrecoverable.

Backing Up the Secret Key

Restoring the Secret Key

Kubernetes:
Traditional deployment:
If you restore a database backup without the matching SECRET_KEY, all encrypted credentials will be unreadable and must be re-created.

Backup Verification

Regularly verify your backups to ensure they’re valid:

Backup Best Practices

  • Production: Daily full backups, hourly incremental if possible
  • Development: Weekly backups or before major changes
  • Critical systems: Consider continuous replication
  • Keep daily backups for 7 days
  • Keep weekly backups for 4 weeks
  • Keep monthly backups for 1 year
  • Adjust based on compliance requirements and storage capacity
  • Store backups in a different physical location or cloud region
  • Use encryption for backups stored in untrusted locations
  • Test restoration from off-site backups regularly
  • Set up alerts for failed backup jobs
  • Monitor backup file sizes for anomalies
  • Track backup duration trends
  • Verify backup completion before purging old backups

Migration and Disaster Recovery

Complete System Migration

To migrate AWX to new infrastructure:
1

Backup current system

Create a full database backup and export the SECRET_KEY:
2

Install AWX on new infrastructure

Deploy AWX using the operator or your preferred method, but don’t start it yet.
3

Restore SECRET_KEY

Apply the secret key to the new cluster:
4

Restore database

Load the database backup:
5

Verify and start

Start AWX and verify all systems are operational. Test credential decryption by running a simple job.

Disaster Recovery Checklist

  • Latest database backup is available and tested
  • SECRET_KEY is backed up securely
  • File-based configuration is backed up
  • Restoration procedure is documented
  • Recovery time objective (RTO) is defined and achievable
  • Recovery point objective (RPO) is defined and met by backup frequency
  • Team members are trained on restoration procedures
  • Disaster recovery procedure is tested quarterly

Troubleshooting

Ensure the backup user has sufficient PostgreSQL permissions:
Use the -c flag to clean the database before restoring:
Verify the SECRET_KEY matches the one used during backup:
If they don’t match, restore the correct SECRET_KEY and restart AWX.
Increase PVC size or clean up old backups:

See Also

  • Configuration — AWX configuration management
  • Security — Credential encryption and security features
  • Metrics — Monitoring backup job performance