Files
hfb_sys/scripts/migrate-minio-to-oss.sh

34 lines
814 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
COMPOSE_FILE="${ROOT_DIR}/deploy/docker-compose.prod.yml"
BACKEND_ENV="${ROOT_DIR}/backend/.env"
usage() {
cat <<'EOF'
用法: ./scripts/migrate-minio-to-oss.sh [--verify|--dry-run] [--prefix 前缀]
迁移配置写入 backend/.env
STORAGE_* 当前 MinIO 源端配置
STORAGE_MIRROR_* 杭州 OSS 目标端配置
命令会复制同名 object key,不删除 MinIO 数据;可重复执行。
EOF
}
if [[ ! -f "${BACKEND_ENV}" ]]; then
echo "未找到 backend/.env" >&2
exit 1
fi
case "${1:-}" in
-h|--help)
usage
exit 0
;;
esac
exec docker compose --env-file "${BACKEND_ENV}" -f "${COMPOSE_FILE}" \
run --rm --no-deps backend /app/hfb-storage-migrate "$@"