Restoring Hue

The backup procedure automatically saved the Hue database content and placed the content into the configured logs or data folders based on availability. Using the saved content, the restore process loads the data for the new Hue deployments.

In the manual backup of Hue, you followed steps to dump the entire Hue database. In the following procedure, you move the Hue backup file from the dump to the new CDW environment.
  • Ensure that at least one Hive Virtual Warehouse or Impala Virtual Warehouse exists. Create a Virtual Warehouse if necessary.
  • Do not open the Hue web interface prior to completing the steps below.
  • During the manual or automatic Hue database restore operation it is critical to block any traffic to the running Hue services. If you cannot bring down the cluster, use the recommended workaround to disable end user access to the cluster endpoints. Failing to do so results in errors in addition to existing key constraints and other issues.
  1. Copy the database backup files to the container.
    $ export VW=<virtual_warehouse_id>
    $ kubectl cp <local_backup_path>/hue_database_backup_schema-only.psql $VW/huebackend-0:/tmp/hue_database_backup_schema-only.psql -c hue
    $ kubectl cp <local_backup_path>/hue_database_backup.psql $VW/huebackend-0:/tmp/hue_database_backup.psql -c hue
  2. Go to Hue container.
    $ kubectl -n $VW exec -i -t huebackend-0 --container hue -- /bin/bash
  3. 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-1702498325-gqmk_huedb"
  4. Get the Hue 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
  5. Resent the Hue database and recreate tables.
    $ ./build/env/bin/hue reset_db -c --router=default
  6. Restore the Hue database from the backup file.
    $ psql -d $HUEDB -h postgres-service -U hive < /tmp/hue_database_backup_schema-only.psql
    $ pg_restore -d $HUEDB -h postgres-service /tmp/hue_database_backup.psql -c -U hive
    $ ./build/env/bin/hue migrate