Restore
- The following directory takes the time 20221111184140 as an example for illustration, in the format of year, month, day, hour, minute, and second.
- The host uses the default data directory
/data/hap/
(which can be viewed viacat /etc/pdcaptain.json
orcat service.sh | grep installDir=
in the root of the manager).
Preparation
- Stop the HAP service. Execute the command
bash . /service.sh stopall
in the root of the manager; - Upload the backup file
20221111184140.tar.gz
to the data restore server, e.g. in the directory/backup/
; - Remove the original data from the current environment (for security, use the mv command first, and if it is OK, delete it completely).
time=$(date +%Y%m%d%H%M%S) && mkdir -p /backup/$time/ && mv /data/hap/script/volume/data/* /backup/$time/
Dump (available in v3.7.1+)
-
Decompress the zip package of the backup file in the directory
/backup/
.tar -zxvf 20221111184140.tar.gz
-
Start the temporary container and mount the data directory.
docker run -it --rm --entrypoint bash -e ENV_MYSQL_HOST="127.0.0.1" -e ENV_MYSQL_PORT="3306" -e ENV_MYSQL_USERNAME="root" -e ENV_MYSQL_PASSWORD="123456" -e ENV_MONGODB_URI="mongodb://127.0.0.1:27017" -e ENV_MONGODB_OPTIONS="" -v /data/hap/script/volume/data/:/data/ -v /backup/:/data/backup/ nocoly/hap-sc:3.0.0
mkdir -p /data/{logs,mysql,mongodb,storage}
mkdir -p /data/storage/data -
Start the mysql server in a temporary container for restoring data.
source /entrypoint.sh && mysqlStartup &
-
Rebuild the mysql database. If there is important data, you need to backup it first before deleting.
source /entrypoint.sh && restore mysql /data/backup/20221111184140/mysql
-
Start the mongodb server in a temporary container for restoring data.
source /entrypoint.sh && mongodbStartup &
Startup will automatically create the index, you need to execute the enter command manually after the creation.
-
Rebuild the mongodb database. If there is important data, you need to backup it first before deleting.
source /entrypoint.sh && restore mongodb /data/backup/20221111184140/mongodb
-
Rebuild the file data.
source /entrypoint.sh && restore file /data/backup/20221111184140/file
-
Exit the temporary container.
-
Execute the command ``bash . /service.sh startall` in the root of the manager to restart the service.
Copy File
-
Upload the zip package of the original backup file to the current server and unzip it to the data directory.
tar -zxvf /backup/20221111184140.tar.gz -C /data/hap/script/volume/data/
-
Execute the command
bash . /service.sh startall
in the root of the manager to restart the service.