Skip to main content

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/mingdao/ (can be viewed through cat /etc/pdcaptain.json or cat service.sh | grep installDir= in the manager root directory)

Preparation

  1. Stop the HDP service and execute bash ./service.sh stopall in the root directory of the manager (stopped is output successfully);
  2. Upload the backup file 20221111184140.tar.gz to the data restoration server, such as storing it in the /backup/ directory;
  3. 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/mingdao/script/volume/data/* /backup/$time/

dump method

  1. Unzip the backup compressed package in the /backup/ directory

    tar -zxvf 20221111184140.tar.gz
  2. 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/mingdao/script/volume/data/:/data/ -v /backup/:/data/backup/ registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-sc:3.2.0
    mkdir -p /data/{logs,mysql,mongodb,storage}
    mkdir -p /data/storage/data
  3. Start the mysql server in the temporary container to restore data

    source /entrypoint.sh && mysqlStartup &
  4. 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
  5. 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

  1. 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
  2. Rebuild file data

    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
    1. Add sc host resolution
    echo '127.0.0.1 sc' >> /etc/hosts
    1. Start minio
    source /entrypoint.sh && minioStartup &
    1. Create bucket
    source /entrypoint.sh && fileInit &
    1. Restore file data
    source /entrypoint.sh && restore file /data/backup/20221111184140/file
  3. Execute exit to exit the temporary container

  4. Clean redis cache data

    mv /data/mingdao/script/volume/data/redis/dump.rdb /data/mingdao/script/volume/data/redis/dump.rdb.bak
  5. Execute bash ./service.sh startall in the root directory of the manager to restart the service

File copy method

  1. 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/mingdao/script/volume/data/
  2. Clean redis cache data

    mv /data/mingdao/script/volume/data/redis/dump.rdb /data/mingdao/script/volume/data/redis/dump.rdb.bak
  3. Execute bash ./service.sh startall in the root directory of the manager to restart the service