github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/qdrant/scripts/qdrant-backup.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -e
     4  set -o pipefail
     5  export PATH="$PATH:$DP_DATASAFED_BIN_PATH"
     6  export DATASAFED_BACKEND_BASE_PATH="$DP_BACKUP_BASE_PATH"
     7  
     8  # if the script exits with a non-zero exit code, touch a file to indicate that the backup failed,
     9  # the sync progress container will check this file and exit if it exists
    10  function handle_exit() {
    11    exit_code=$?
    12    if [ $exit_code -ne 0 ]; then
    13      echo "failed with exit code $exit_code"
    14      touch "${DP_BACKUP_INFO_FILE}.exit"
    15      exit 1
    16    fi
    17  }
    18  trap handle_exit EXIT
    19  
    20  endpoint=http://${DP_DB_HOST}:6333
    21  
    22  snapshot=$(curl -XPOST ${endpoint}/snapshots)
    23  status=$(echo ${snapshot} | jq '.status')
    24  if [ "${status}" != "ok" ] && [ "${status}" != "\"ok\"" ]; then
    25    echo "backup failed, status: ${status}"
    26    exit 1
    27  fi
    28  
    29  name=$(echo ${snapshot} | jq -r '.result.name')
    30  curl -v --fail-with-body ${endpoint}/snapshots/${name} | datasafed push - "/${DP_BACKUP_NAME}.snapshot"
    31  
    32  curl -XDELETE ${endpoint}/snapshots/${name}
    33  
    34  TOTAL_SIZE=$(datasafed stat / | grep TotalSize | awk '{print $2}')
    35  echo "{\"totalSize\":\"$TOTAL_SIZE\"}" >"${DP_BACKUP_INFO_FILE}"