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.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
Usepg_dump to create a complete backup of the AWX database:
-F c— Custom format (compressed, supports selective restore)-F p— Plain SQL format (human-readable)-F t— Tar format
Scheduled Backups
Create a cron job for automated daily backups:- 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
-c— Clean (drop) database objects before recreating-C— Create the database before restoring--if-exists— Use with-cto suppress errors if objects don’t exist
Restore from SQL Format
AWX Operator Backup
The AWX Operator provides built-in backup and restore capabilities for Kubernetes-based deployments.Creating Operator Backups
Define anAWXBackup custom resource:
awx-backup.yaml
Scheduled Operator Backups
Create a CronJob for automated backups:awx-backup-cronjob.yaml
Restoring from Operator Backup
Define anAWXRestore custom resource:
awx-restore.yaml
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:Secret Key Management
TheSECRET_KEY is critical for encrypting sensitive data. Losing it makes encrypted credentials unrecoverable.
Backing Up the Secret Key
Restoring the Secret Key
Kubernetes: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
Backup frequency
Backup frequency
- Production: Daily full backups, hourly incremental if possible
- Development: Weekly backups or before major changes
- Critical systems: Consider continuous replication
Retention policy
Retention policy
- 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
Off-site storage
Off-site storage
- 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
Backup monitoring
Backup monitoring
- 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:Install AWX on new infrastructure
Deploy AWX using the operator or your preferred method, but don’t start it yet.
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
Backup fails with permission errors
Backup fails with permission errors
Ensure the backup user has sufficient PostgreSQL permissions:
Restore fails with constraint violations
Restore fails with constraint violations
Use the
-c flag to clean the database before restoring:Credentials not decrypting after restore
Credentials not decrypting after restore
Verify the SECRET_KEY matches the one used during backup:If they don’t match, restore the correct SECRET_KEY and restart AWX.
AWX Operator backup PVC full
AWX Operator backup PVC full
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