Skip to content

Backup Data

Backing up and restoring data requires using the scripts introduced in Data Backup and Restore, with the distinction that the following operations are performed within the container.

The metadb backup is executed in the hengshi-metadb container.

The engine backup and restore are executed in the hengshi-engine container.

The minio backup and restore are executed in the hengshi-minio container.

Please Note

In the Docker environment, only the local backup method is used, and backups are stored in the backup directory under HSHOME configured in .env. The default path is docker-compose-x.x/hsdata/backup. After restoring the data, please verify the correctness of the data before deleting the old data!

Backup and Restore metadb

Follow the steps in the example to back up and restore metadb.

  • Example of backing up metadb.
shell
# Enter the metadb container and create a backup directory
docker exec -it hengshi-metadb mkdir -p /opt/hsdata/backup
# Start the backup
docker exec -it hengshi-metadb /opt/hengshi/bin/dbbackup.sh -m metadb -l /opt/hsdata/backup
  • Example of restoring metadb.

Stop all services (or just stop the hengshi service)

shell
cd docker-compose-x.x
docker-compose down

Rename the old data directory

shell
sudo mv ${HSHOME}/hsdata/pg_data ${HSHOME}/hsdata/pg_data.old

Please note

${HSHOME} is a placeholder variable and cannot be directly copied and pasted! Replace it with your actual deployment directory.

For example:

If hengshi is deployed in /data/docker-compose-6.0, the actual path would be sudo mv /data/docker-compose-6.0/hsdata/pg_data /data/docker-compose-6.0/hsdata/pg_data.old.

Reinitialize the new metadb data for backup import

shell
docker-compose run --rm metadb init metadb
docker-compose up -d metadb
docker exec -it hengshi-metadb /opt/hengshi/bin/dbrestore.sh -m metadb -l /opt/hsdata/backup -t metadb_backup.xx-xx-xx_xx:xx:xx.tar.gz
docker-compose down
  • After successfully restoring metadb, restart the system.
shell
docker-compose up -d

Backup and Restore Engine Data

Follow the steps in the example to back up and restore engine data.

  • Example of backing up engine data.
shell
docker exec -it hengshi-engine mkdir -p /opt/hsdata/backup
docker exec -it hengshi-engine /opt/hengshi/bin/dbbackup.sh -m engine -l /opt/hsdata/backup
  • Example of restoring engine data.

Stop all services (or just stop the hengshi service)

shell
cd docker-compose-x.x
docker-compose down

Rename the old data directory

shell
sudo mv ${HSHOME}/hsdata/engine-cluster ${HSHOME}/hsdata/engine-cluster.old

Please note

${HSHOME} is a placeholder variable and cannot be directly copied and pasted! Replace it with your actual deployment directory.

For example:

If hengshi is deployed in /data/docker-compose-5.1, the actual path would be: sudo mv /data/docker-compose-5.1/hsdata/engine-cluster /data/docker-compose-5.1/hsdata/engine-cluster.old.

  1. Reinitialize new engine data and import the backup
shell
docker-compose run --rm engine init engine
docker-compose up -d engine
docker exec -it hengshi-engine /opt/hengshi/bin/dbrestore.sh -m engine -l /opt/hsdata/backup -t engine_backup.xx-xx-xx_xx:xx:xx.tar.gz
docker-compose down
  • After the engine is successfully restored, restart the system.
shell
docker-compose up -d

Backup and Restore Minio

Follow the steps in the example to back up and restore Minio.

  • Minio backup example.
shell
docker exec -it hengshi-minio mkdir -p /opt/hsdata/backup
docker exec -it hengshi-minio /opt/hengshi/bin/dbbackup.sh -m minio -l /opt/hsdata/backup
  • Minio restore example.

Stop all services (or just stop Hengshi services)

shell
cd docker-compose-x.x
docker-compose down

Rename the old data directory

shell
sudo mv ${HSHOME}/hsdata/minio-data ${HSHOME}/hsdata/minio-data.old

Please note

${HSHOME} is a placeholder variable and cannot be directly copied and pasted! Replace it with your actual deployment directory.

For example:

If Hengshi is deployed in /data/docker-compose-5.1, the actual path would be sudo mv /data/docker-compose-5.1/hsdata/minio-data /data/docker-compose-5.1/hsdata/minio-data.old.

Minio does not require initialization; after starting, you can directly import the backup.

shell
docker-compose up -d minio
docker exec -it hengshi-minio /opt/hengshi/bin/dbrestore.sh -m minio -l /opt/hsdata/backup -t minio_backup.xx-xx-xx_xx:xx:xx.tar.gz
docker-compose down
  • After Minio is successfully restored, restart the system.
shell
docker-compose up -d

User Manual for Hengshi Analysis Platform