How to Exclude Old Job Events in The Ansible Automation Platform 2.0+ Backup / Restore?

Solution Verified - Updated -


  • Ansible Automation Platform 2.0+


  • I want the backup-restore process to skip backing up and restoring old job event data.


  • Unlike Ansible Tower, "main_jobevent" is partitioned table in Ansible Automation Platform. In order to exclude old Job Events in AAP 2.0+, you need to modify following files from backup roles.

  • For setup script to exclude the main_jobevent tables, make the following edit:


    # clean drops the database
    # create adds instructions to create the database
    # Note: user needs access to postgres template when restoring
    - name: Perform a PostgreSQL dump.
      shell: |
       pg_dump \
         --clean --create \
         --host='{{ controller_db_settings.default.HOST }}' \
         --port={{ controller_db_settings.default.PORT }} \
         --username='{{ controller_db_settings.default.USER  }}' \
         --dbname='{{ controller_db_settings.default.NAME }}' \
         --exclude-table-data=main_jobevent* \                        <<<<<<<<< HERE <<<<<<<<<
         --exclude-table-data=_unpartitioned_main_jobevent \          <<<<<<<<< HERE <<<<<<<<<
         --exclude-table=main_instance \
         --exclude-table=main_instancegroup \
         --exclude-table=main_instancegroup_instances > tower.db
      chdir: '{{ backup_dir.rstrip("/") }}/common/'
    environment: "{{ {'PGPASSWORD': 
    controller_db_settings.default.PASSWORD} | combine( extra_env | default({}) ) }}"
    register: psql_command
    failed_when: "'ERROR' in psql_command.stderr"
    no_log: True 
  • This will allow the installer to handle that data without backing up.

  • Please note, there is no need to modify the restore task like Ansible Tower here.

Root Cause

  • Sometimes it could be necessary due to problems related to the size of the tables and storage problems.

    Note - This procedure is useful when you are backing up data in order to be restored in a different database.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.