Skip to content

Instantly share code, notes, and snippets.

@topikachu
Last active July 7, 2025 08:21
Show Gist options
  • Select an option

  • Save topikachu/6aeda4016a994c1a92b8e62a8e6ead6b to your computer and use it in GitHub Desktop.

Select an option

Save topikachu/6aeda4016a994c1a92b8e62a8e6ead6b to your computer and use it in GitHub Desktop.
backup milvus and copy the backup to disk
#!/usr/bin/env bash
echo "Backup started at $(date)"
which -s s5cmd
if [[ $? -ne 0 ]]; then
echo "s5cmd not found. Please install s5cmd from https://github.com/peak/s5cmd/releases"
exit 1
fi
which -s milvus-backup
if [[ $? -ne 0 ]]; then
echo "milvus-backup not found. Please install milvus-backup from https://github.com/zilliztech/milvus-backup/releases"
exit 1
fi
which -s yq
if [[ $? -ne 0 ]]; then
echo "yq not found. Please install yq from https://github.com/mikefarah/yq"
exit 1
fi
# Change to the directory containing the script
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR" || exit 1
if [[ ! -f "configs/backup.yaml" ]]; then
echo "Backup configuration file 'configs/backup.yaml' not found. Please check https://github.com/zilliztech/milvus-backup/blob/main/configs/backup.yaml"
exit 1
fi
set -e
export BACKUP_DIR=${BACKUP_DIR:=/tmp/milvus_backup}
export AWS_ACCESS_KEY_ID=$(yq eval '.minio.accessKeyID' configs/backup.yaml)
export AWS_SECRET_ACCESS_KEY=$(yq eval '.minio.secretAccessKey' configs/backup.yaml)
export AWS_DEFAULT_REGION=$(yq eval '.minio.region' configs/backup.yaml)
S3_ADDRESS=$(yq eval '.minio.address' configs/backup.yaml)
S3_PORT=$(yq eval '.minio.port' configs/backup.yaml)
S3_USE_SSL=$(yq eval '.minio.useSSL' configs/backup.yaml)
if [ "$S3_USE_SSL" = "true" ]; then
export S3_ENDPOINT_URL="https://${S3_ADDRESS}:${S3_PORT}"
else
export S3_ENDPOINT_URL="http://${S3_ADDRESS}:${S3_PORT}"
fi
export BACKUP_NAME="backup$(date +%Y%m%d%H%M%S)"
export MINIO_BUCKET_NAME=$(yq eval '.minio.bucketName' configs/backup.yaml)
export MINIO_BACKUP_BUCKET_NAME=$(yq eval '.minio.backupBucketName' configs/backup.yaml)
milvus-backup check
s5cmd ls
milvus-backup create -n $BACKUP_NAME
s5cmd ls "s3://${MINIO_BACKUP_BUCKET_NAME}/backup/$BACKUP_NAME/"
s5cmd sync "s3://${MINIO_BACKUP_BUCKET_NAME}/backup/$BACKUP_NAME/*" $BACKUP_DIR/$BACKUP_NAME
echo "Backup completed at $(date)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment