Back Up & Restore

The following guide provides high-level instructions for backing up and restoring the HPE Machine Learning Inferencing Software PostgreSQL database. Regular backups of the database should be made as part of your business continuity plan. For detailed information on how to perform a backup, refer to the official PostgreSQL documentation.

Back Up the Database

  1. Connect to the database container.
  2. Create a backup of the database using the pg_dump command:
    AIOLI_DATABASE_DUMP="aioli_db_dump_$(date +%F).sql"
    kubectl exec -i -t svc/aioli-db-service-aioli -- pg_dump --username postgres aioli > ${AIOLI_DATABASE_DUMP}

Example Backup Policy

Establishing a backup policy is essential to ensure that your data is protected and can be restored in the event of data loss. The following is a basic example:

  • Daily Backups: Perform a full backup every night at 2 AM.
  • Incremental Backups: Perform hourly incremental backups.
  • Retention: Retain daily backups for 7 days, weekly backups for 4 weeks, and monthly backups for 6 months.
  • Restoration: Test the restore process quarterly to ensure backups are valid and restoration steps are clear.

Restore the Database

  1. Scale down the deployment to prevent any changes to the database during the restoration process:
    kubectl scale deployment aioli-master-deployment-<releaseName> --replicas=0
  2. Monitor the state of the deployment until all aioli-master pods are terminated:
    watch -n 5 kubectl get pods
  3. Restore the database using the psql command:
    kubectl exec -i svc/aioli-db-service-aioli -- psql --username postgres aioli < ${AIOLI_DATABASE_DUMP}
  4. Scale up the deployment to restore normal operation:
    kubectl scale deployment aioli-master-deployment-<releaseName> --replicas=1

The AIOLI control process will restart automatically and perform any necessary database migrations so that your restored database and present HPE Machine Learning Inferencing Software software versions remain compatible.

Re-create the Database

The following re-creates a new, empty database named aioli:

kubectl exec -i svc/aioli-db-service-aioli -- createdb --username postgres -T template0 aioli