Backing up Hue

Backing up Hue is an automated process that saves the Hue database content. The process places the content in configured logs or data folders based on availability. If, for any reason, you want to manually back up the database, you can choose to do so.

  • You must temporarily deploy at least one Virtual Warehouse that runs 2023.0.14.0-15 or later to your environment as described in the steps below if you meet both of the following conditions:
    • You have not deployed Runtime version 2023.0.14.0-15 (released May 5, 2023) or later in any Virtual Warehouse in your cluster.
    • You have deployed only Runtime version 2023.0.13.0-20 (released Feb 7, 2023) or earlier in any Virtual Warehouse in your cluster.
    1. Create a Virtual Warehouse that runs 2023.0.14.0-15 or later.
    2. Delete the Virtual Warehouse you just created.

      The steps above resolve a Hue schema incompatibility issue before backing up and restoring Hue.

Manual backup

If anything goes wrong with the automatic backup of Hue, or if you just prefer a manual process, you can back up Hue manually. You can choose to manually save and restore the Hue data to keep the Hue saved queries and query history for your Virtual Warehouses on the new cluster.

One Hue database is shared between all Virtual Warehouses, so you execute the following steps only once. To back up Hue, follow steps below to create a Postgres dump.
  1. Go to the Hue container.
    $ export VW=<virtual_warehouse_id>
    $ kubectl -n $VW exec -i -t huebackend-0 --container hue -- /bin/bash
  2. Check the Hue database configuration.
    $ vi /etc/hue/conf/zhuei.ini
                    
    Example of content:
    [[database]]
    engine=postgres
    host="postgres-service"
    port=5432
    user="hive"
    password_script=/etc/hue/conf/altscript.sh hue_database_password
    name="warehouse-1702498301-jjtw_huedb"
  3. Get database name and password
    $ IFS="=" read nameKey HUEDB <<< $(cat /etc/hue/conf/zhue.ini | grep huedb | sed 's/"//g')
    $ /etc/hue/conf/altscript.sh hue_database_password; echo
  4. Dump the database backup file and input password when prompted.
    $ pg_dump -h postgres-service -U hive --schema-only -W $HUEDB > /tmp/hue_database_backup_schema-only.psql
    $ pg_dump -h postgres-service -U hive -W -F c $HUEDB > /tmp/hue_database_backup.psql
  5. Copy the database backup file to a local backup path.
    $ kubectl cp $VW/huebackend-0:/tmp/hue_database_backup_schema-only.psql -c hue <local_backup_path>/hue_database_backup_schema-only.psql
    $ kubectl cp $VW/huebackend-0:/tmp/hue_database_backup.psql -c hue <local_backup_path>/hue_database_backup.psql