Restore
- Before restoring, pay attention to the current disk capacity usage. The remaining space needs to be twice or more than the capacity used by the data before the backup to avoid the disk capacity being full during the restore.
- The following directory uses the time point 20221111184140 as an example, format: year, month, day, hour, minute, second
- The host uses the default data directory
/data/hap/(can be viewed throughcat /etc/pdcaptain.jsonorcat service.sh | grep installDir=in the manager root directory)
Preparation
- Stop the HDP service and execute
bash ./service.sh stopallin the root directory of the manager (stopped is output successfully); - Upload the backup file
20221111184140.tar.gzto the data restoration server, such as storing it in the/backup/directory; - Remove the original data in the current environment (for safety reasons, use the mv command first, and then delete it completely after running smoothly)
time=$(date +%Y%m%d%H%M%S) && mkdir -p /backup/$time/ && mv /data/hap/script/volume/data/* /backup/$time/
dump method
-
Unzip the backup compressed package in the
/backup/directorytar -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/sc:3.2.0mkdir -p /data/{logs,mysql,mongodb,storage}mkdir -p /data/storage/data -
Start the mysql server in the temporary container to restore data
source /entrypoint.sh && mysqlStartup & -
Rebuild the mysql database. If there is any important data, back it up and then delete it.
source /entrypoint.sh && restore mysql /data/backup/20221111184140/mysql -
Start the mongodb server in the temporary container to restore data
source /entrypoint.sh && mongodbStartup &
The index will be automatically created at startup. After the index creation is completed, you need to manually execute the Enter command
-
Rebuild the mongodb database. If there is any important data, back it up and then delete it.
source /entrypoint.sh && restore mongodb /data/backup/20221111184140/mongodb -
Rebuild file data
- Microservice version>=5.2.0
- Microservice version<5.2.0
Note: If the newly deployed microservice version is 5.2.0+ (filev2: 5.2.0+ uses minio + file mode), you need to manually start the minio service in the container and create a bucket- Add sc host resolution
echo '127.0.0.1 sc' >> /etc/hosts- Start minio
source /entrypoint.sh && minioStartup &- Create bucket
source /entrypoint.sh && fileInit &- Restore file data
source /entrypoint.sh && restore file /data/backup/20221111184140/filesource /entrypoint.sh && restore file /data/backup/20221111184140/file -
Execute exit to exit the temporary container
-
Clean redis cache data
mv /data/hap/script/volume/data/redis/dump.rdb /data/hap/script/volume/data/redis/dump.rdb.bak -
Execute
bash ./service.sh startallin the root directory of the manager to restart the service
File copy method
-
Upload the compressed package of the original backup to the current server and decompress it to the data directory
tar -zxvf /backup/20221111184140.tar.gz -C /data/hap/script/volume/data/ -
Clean redis cache data
mv /data/hap/script/volume/data/redis/dump.rdb /data/hap/script/volume/data/redis/dump.rdb.bak -
Execute
bash ./service.sh startallin the root directory of the manager to restart the service