Administrator Guide > Monitoring Axon > Back Up and Restore Database
  

Back Up and Restore Database

Axon automatically backs up the PostgreSQL database according to the predefined schedule. You can also back up the Axon PostgreSQL database manually and restore it to another instance of the same Axon version.
You might want to back up and restore the Axon database under the following circumstances:
When Axon backs up the database automatically, the backup scheduler keeps the last 10 backups at the following location: <INSTALLATION_DIR>/axonhome/db-backups/postgres_backups/

Back Up Database

To back up the database, run the script file axon_db_backup.sh that contains the details of the backup. Perform the following tasks to back up the Axon database at the source location.
    1. Go to the <INSTALLATION_DIR>/scripts directory and run the following command to back up the database:
    sh axon_db_backup.sh <BACKUP_DESTINATION_DIR>
    2. Go to the backup destination directory to verify that the database backup file has been created. The database backup is an SQL file with the timestamp: <BACKUP_DESTINATION_DIR>/<backup_sql_file>
    For example, your backup file might look like this: <BACKUP_DESTINATION_DIR>/postgres_2018_06_24_025744.sql

Restore Database

Perform the following tasks to restore the Axon database to the destination location:
    1. Go to the <INSTALLATION_DIR>/bin destination location where you have installed Axon and run the following command to shut down the Axon instance:
    sh shutdown.sh
    2. Go to the <INSTALLATION_DIR>/axonhome/third-party-app/scripts directory, and run the following command to restart the PostgreSQL database service:
    sh postgresql restart
    3. Run the following command to define the Axon environment variable so that the Linux system can access the Axon resources at the correct location:
    source <INSTALLATION_DIR>/scripts/exportEnv.sh
    4. Run the following command to restore the database from the backup file:
    <INSTALLATION_DIR>/axonhome/third-party-app/postgresql/bin/psql -U <Axon_Admininstrator> -d postgres -h localhost -f <full_path_to_backup_postgresql_file>
    For example, run the following command:
    <INSTALLATION_DIR>/axonhome/third-party-app/postgresql/bin/psql -U noot -d postgres -h localhost -f <BACKUP_DESTINATION_DIR>/postgres_2018_06_24_025744.sql
    You can ignore any user or role error message that might be displayed.

Restore Axon Settings

After copying the database, perform the following tasks to restart Axon, reindex the database, and restore the Axon settings.
    1. Reapply your Axon customization settings in the .ymlc or .yml files.
    2. Go to the <DESTINATION_INSTALLATION_DIR>/bin location and run the following command to start Axon:
    sh startup.sh
    3. Go to the <DESTINATION_INSTALLATION_DIR>/scripts directory and run the following script to reindex the database:
    sh reIndex.sh
    4. Check the Enterprise Data Catalog and Informatica Data Quality settings to make sure that they point to the destination Axon instance.
    5. Verify that all Axon services are running properly. Log in to Axon as an administrator, go to the Admin Panel, and view the Admin Dashboard. The Status of Axon Services section shows the services that are operational.

Backup and Restore Admin Activity History

When you migrate Axon from one instance to another, you must manually migrate the admin activity history. The admin activity history is stored in the Elasticsearch database.
    1. Run the following commands in the Linux environment to take a snapshot of the admin activity history data:
    TIMESTMP=`date +%m%d%Y%H%M%S`
    SNAPSHOT_NAME="upgrade-snapshot-$TIMESTMP"
    . <OLD_INSTALLATION_DIR>/scripts/elasticsearch_backup.sh $SNAPSHOT_NAME
    2. Copy the snapshot files from the <OLD_INSTALLATION_DIR>/scripts/axonhome/elasticsearch_backup directory to the <NEW_INSTALLATION_DIR>/axonhome/elasticsearch_backup/ directory.
    3. Run the following commands to restore the admin activity history to the new Axon instance:
    . <NEW_INSTALLATION_DIR>/scripts/elasticsearch_restore.sh $SNAPSHOT_NAME
    rm -rf <NEW_INSTALLATION_DIR>/axonhome/elasticsearch_backup/*
    sh <NEW_INSTALLATION_DIR>/axonhome/third-party-app/scripts/elasticsearch restart true
    sh <NEW_INSTALLATION_DIR>/axonhome/third-party-app/scripts/logstash restart true