How to backup Autojoin data from Redis in HipChat Server

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

Autojoin data contains the room and 1-1 chat listings for the HipChat clients sidebar. This data is not stored on disk on the server, but instead inside of Redis cache. The following outlines how to backup this specific data from the Redis server running locally inside HipChat Server.

This will not work for HipChat Data Center (since Redis is running externally and requires hostname and authentication arguments to gain access to the Redis CLI).

Backup Autojoin Data from Redis

  1. Log into the HipChat Server command line interface.
  2. Gain root access:

    sudo dont-blame-hipchat
  3. Create a temporary directory to house the lists and switch to that directory.

    mkdir /home/admin/autojoin_temp && cd /home/admin/autojoin_temp
  4. Run the following for loop. This will iterate through the Redis cache and pull out each of the user specific autojoin keys, assign a label and save them to disk for each one.

    for key in $(redis-cli KEYS "*autoJoin*" | sed 's/^[1-9][0-9]*) //g'); do echo "[$(date +%Y-%m-%dT%H:%M:%S)] Exporting $key"; redis-cli GET $key > ${key}.value; done
  5. Once this is completed, you will see several files labeled 'pref:autoJoin:n.value' in the /home/admin/autojoin_temp folder. The following command will tar those files up into a redis_exports.tgz file:

    tar czvf redis_exports.tgz pref\:autoJoin*
  6. Next, we can cleanup the autojoin files that were just added to the redis_exports.tgz archive

    rm pref\:autoJoin*
  7. (Optional) Append the date timestamp to the newly created archive file.

    mv redis_exports.tgz redis_exports_$(date +%Y-%m-%d-%H-%M-%S).tgz

Restore Autojoin Data from Redis

  1. While in the HipChat Server command line interface as root, locate the redis_exports_<date>.tgz backup archive.
  2. Create or navigate to a temp folder that is empty and change to that directory.
  3. Uncompress this archive into this temp directory:

    tar xzvf /path/to/redis_exports_<date>.tgz
  4. Run the following command to iterate placing the autojoin data back into Redis:

    for file in $(ls pref\:autoJoin*.value); do key=$(echo $file | sed 's/.value//g'); value=$(cat $file); echo "[$(date +%Y-%m-%dT%H:%M:%S)] Import $key from $file"; redis-cli SET $key "$value"; done
  5. After the new keys are imported, delete the pref:autoJoin:n.value files:

    rm pref\:autoJoin*

Additional Notes

  • This will only backup the autojoin data for users that have an autojoin value in Redis.
  • This will not backup user accounts or any other data in the database or in cache.


Last modified on Oct 26, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.