Backup Data
Backup and restore data require the use of the scripts introduced in Data Backup and Restore. The difference is that all operations are performed within the container.
Metadb backup is executed in the hengshi-metadb container.
Engine backup and restore are executed in the hengshi-engine container.
Minio backup and restore are executed in the hengshi-minio container.
Please note
In a docker environment, only local backup methods are used, and the backup is stored in the backup directory under HSHOME configured in .env, with the default path being docker-compose-x.x/hsdata/backup. After data recovery, please confirm the correctness of the data before deleting the old data!
Backup and Restore Metadb
Follow the steps in the example to backup and restore metadb.
- Example of backing up metadb.
# Enter the metadb container to create a backup directory
docker exec -it hengshi-metadb mkdir -p /opt/hsdata/backup
# Start 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)
cd docker-compose-x.x
docker-compose down
Rename the old data directory
sudo mv ${HSHOME}/hsdata/pg_data ${HSHOME}/hsdata/pg_data.old
Please note
${HSHOME} is an example variable and cannot be directly copied and pasted! Please replace it with your actual deployment directory.
For example:
hengshi is deployed in /data/docker-compose-5.1, the actual path would be sudo mv /data/docker-compose-5.1/hsdata/pg_data /data/docker-compose-5.1/hsdata/pg_data.old.
Reinitialize the new metadb data for backup import
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
- When metadb recovery is successful, restart the system.
docker-compose up -d
Backup and Restore Engine Data
Follow the steps in the example to backup and restore engine data.
- Example of backing up engine data.
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)
cd docker-compose-x.x
docker-compose down
Rename the old data directory
sudo mv ${HSHOME}/hsdata/engine-cluster ${HSHOME}/hsdata/engine-cluster.old
Please note
${HSHOME} is an example variable and cannot be directly copied and pasted! Please replace it with your actual deployment directory.
For example:
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.
Reinitialize the new engine data for backup import
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
- When engine recovery is successful, restart the system.
docker-compose up -d
Backup and Restore Minio
Follow the steps in the example to backup and restore minio.
- Example of backing up minio.
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
- Example of restoring minio.
Stop all services (or just stop the hengshi service)
cd docker-compose-x.x
docker-compose down
Rename the old data directory
sudo mv ${HSHOME}/hsdata/minio-data ${HSHOME}/hsdata/minio-data.old
Please note
${HSHOME} is an example variable and cannot be directly copied and pasted! Please replace it with your actual deployment directory.
For example:
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 need to be initialized, it can be directly backed up after startup
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
- When minio recovery is successful, restart the system.
docker-compose up -d