Skip to main content

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

Preparation

  1. Stop the HAP service. Execute the command bash . /service.sh stopall in the root of the manager;
  2. Upload the backup file 20221111184140.tar.gz to the data restore server, e.g. in the directory /backup/;
  3. 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/mingdao/script/volume/data/* /backup/$time/

Dump (available in v3.7.1+)

  1. Decompress the zip package of the backup file in the directory /backup/.

    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.0.0
    mkdir -p /data/{logs,mysql,mongodb,storage}
    mkdir -p /data/storage/data
  3. Start the mysql server in a temporary container for restoring data.

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

  6. 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
  7. Rebuild the file data.

    source /entrypoint.sh && restore file /data/backup/20221111184140/file
  8. Exit the temporary container.

  9. Execute the command ``bash . /service.sh startall` in the root of the manager to restart the service.

Copy File

  1. 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/mingdao/script/volume/data/
  2. Execute the command bash . /service.sh startall in the root of the manager to restart the service.