Bookmark this page

Backing up and Restoring Red Hat Ansible Automation Platform

Objectives

  • Back up and restore the automation controller and automation hub databases and configuration files.

Backing up Red Hat Ansible Automation Platform

The ability to manually back up and restore a Red Hat Ansible Automation Platform installation is integrated into the Ansible Automation Platform installation software. After you make a backup, you can use other tools to make sure that the backup files are stored in a safe and secure location.

The backup procedure uses the same setup.sh script and the same inventory file that you used to install your Ansible Automation Platform environment.

Important

If you deleted the original installation directory, you can download and install or unpack the installation files for the same version of Red Hat Ansible Automation Platform that you have installed.

If you do, then you must edit the inventory file in the installation directory to match the one that you used for installation. (That is, it should match your current installation settings.)

To start the backup, run the ./setup.sh -b command in the installation directory as the root user.

The script creates a backup archive file named automation-platform-DATE.tar.gz, where DATE is the current date and time in the date +%F-%T format. The backup script creates the backup archive in the same directory as the setup.sh script and also creates a symbolic link named automation-platform-backup-latest.tar.gz that points to the most recent backup archive.

The backup archive consists of additional archive files that vary based on your installation.

  • The backup script creates an archive for each controller, such as control1.example.com.tar.gz and control2.example.com.tar.gz. These archives contain conf and projects directories. The conf directory contains configuration files from the /etc/tower directory. The projects directory contains project lock files for projects that have been synchronized by the automation controller host. This projects directory does not contain any files from the projects themselves.

  • The backup script also creates the common.tar.gz archive. This archive contains the SECRET_KEY, tower.db, and version files from the database. The tower.db file is a PostgreSQL database dump file. The version file displays the version of Ansible Automation Platform at the time of the backup.

  • If your installation included private automation hub, then the backup script creates the automationhub.tar.gz archive. This archive contains configuration files for private automation hub.

Ensure that you have enough free space available before running the backup.

This procedure backs up the configuration of your Ansible Automation Platform servers, but it does not back up log files or installed programs.

Warning

The manual backup procedure using setup.sh -b only creates the backup archive file. You are responsible for setting up a procedure to periodically create a backup and store the backup archive in a safe place.

Backup Procedure

The following procedure creates a new backup of your Ansible Automation Platform environment.

  1. As the root user, change to the installation directory.

    In the following example, the installer has been extracted to the /opt/ansible-automation-platform/installer directory.

    [root@host ~]# cd /opt/ansible-automation-platform/installer
  2. As the root user, run the setup.sh script with the -b option to start the backup process.

    [root@host installer]# ./setup.sh -b
    ...output omitted...
    
    PLAY RECAP *********************************************************************
    control1.example.com : ok=59  changed=33  ...  failed=0  skipped=85  ...
    hub.example.com      : ok=37  changed=14  ...  failed=0  skipped=67  ...
    localhost            : ok=2   changed=0   ...  failed=0  skipped=0   ...
    
    The setup process completed successfully.
    [warn] /var/log/tower does not exist. Setup log saved to backup.log.
  3. List the automation-platform-* files in the current directory to ensure that the backup archive exists and is accessible.

    [root@host installer]# ls -l automation-platform-*
    -rw-------. ... automation-platform-backup-2022-06-30-10:02:40.tar.gz
    lrwxrwxrwx. ... automation-platform-backup-latest.tar.gz -> /opt/ansible-automation-platform/./automation-platform-backup-2022-06-30-10:02:40.tar.gz

    Note

    The automation-platform-backup-latest.tar.gz symbolic link points to the most recent backup archive. When performing a recovery, the recovery script uses this symbolic link by default.

Restoring Ansible Automation Platform from Backup

Run the setup.sh script with the -r option to restore Ansible Automation Platform from a backup archive. You need the backup archive, the setup.sh script for the same version of Ansible Automation Platform that was used to create the backup, and the inventory file for the installer.

If you have multiple backup archives available, make sure that the automation-platform-backup-latest.tar.gz symbolic link points to the exact backup file from which you want to restore. If you need to use an earlier backup file, delete the existing automation-platform-backup-latest.tar.gz symbolic link and create a new link pointing to the correct backup archive.

Warning

When restoring a backup, make sure you use the same version of Ansible Automation Platform that you used to create the backup.

If you do not remember the exact version you used to create the backup, the common.tar.gz archive in the backup archive file contains a file named version that specifies that software version.

Restoration Procedure

The following procedure demonstrates how to restore the Ansible Automation Platform infrastructure from an existing backup archive.

  1. As the root user, change to the extracted archive directory. In the following example, the installation archive has been extracted and moved to the /opt/ansible-automation-platform/installer directory. The /opt/ansible-automation-platform/installer directory contains the backup archive file.

    [root@host ~]# cd /opt/ansible-automation-platform/installer
  2. Ensure that the backup archive is in that directory.

    [root@host installer]# ls -l automation-platform-*
    -rw-------. ... automation-platform-backup-2022-06-30-10:02:40.tar.gz
    lrwxrwxrwx. ... automation-platform-backup-latest.tar.gz -> /opt/ansible-automation-platform/./automation-platform-backup-2022-06-30-10:02:40.tar.gz

    Important

    The symbolic link automation-platform-backup-latest.tar.gz points to the latest backup archive. If you need to restore from an earlier backup, you have to recreate that link so that it points to the correct archive.

  3. As the root user, run setup.sh -r to start the recovery process.

    Important

    Remember to use the -r option with the setup.sh script. If you forget, then the setup.sh script performs a clean installation but does not restore your backup.

    If that happens, wait until the installation process finishes and then restore the backup.

    [root@host installer]# ./setup.sh -r
    ...output omitted...
    PLAY RECAP *********************************************************************
    control2.lab.com : ok=53   changed=16  ...  failed=0  skipped=56  ...  ignored=2
    control1.lab.com : ok=60   changed=21  ...  failed=0  skipped=85  ...  ignored=2
    db.example.com   : ok=6    changed=6   ...  failed=0  skipped=0   ...  ignored=0
    hub.example.com  : ok=35   changed=13  ...  failed=0  skipped=56  ...  ignored=1
    
    The setup process completed successfully.
    [warn] /var/log/tower does not exist. Setup log saved to restore.log.
  4. Log in to the automation controller web UI and verify that automation controller has been restored correctly from backup.

  5. Log in to the private automation hub web UI and verify that automation hub has been restored correctly from backup.

Revision: do467-2.2-08877c1