All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m37s
新增苹果IAP相关接口与逻辑,包括产品列表查询、交易绑定、状态查询和恢复购买功能。移除旧的IAP验证逻辑,重构订阅系统以支持苹果IAP交易记录存储和权益计算。 - 新增/pkg/iap/apple包处理JWS解析和产品映射 - 实现GET /products、POST /attach、POST /restore和GET /status接口 - 新增apple_iap_transactions表存储交易记录 - 更新文档说明配置方式和接口规范 - 移除旧的AppleIAP验证和通知处理逻辑
77 lines
2.4 KiB
Bash
77 lines
2.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Configuration
|
|
CONTAINER_NAME="ppanel-db"
|
|
DB_USER="vmanroot"
|
|
DB_PASSWORD="vmanrootpassword" # Replace with actual password
|
|
DB_NAME="ppanel" # Explicitly specify the database name
|
|
BACKUP_DIR="/root/db_backups"
|
|
UPLOADER_PATH="/root/uploader-linux-amd64" # Path to your go uploader binary
|
|
RETENTION_DAYS=7
|
|
|
|
# Create backup directory if not exists
|
|
mkdir -p "$BACKUP_DIR"
|
|
|
|
# Generate timestamp
|
|
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
|
FILENAME="mysql_backup_${TIMESTAMP}.sql"
|
|
FILEPATH="${BACKUP_DIR}/${FILENAME}"
|
|
GZ_FILEPATH="${FILEPATH}.gz"
|
|
|
|
# 1. Dump MySQL database from Docker container
|
|
echo "[$(date)] Starting MySQL backup from container ${CONTAINER_NAME}..."
|
|
|
|
# Check if container is running
|
|
if [ ! "$(docker ps -q -f name=${CONTAINER_NAME})" ]; then
|
|
echo "Error: Container ${CONTAINER_NAME} is not running!"
|
|
exit 1
|
|
fi
|
|
|
|
# Execute dump
|
|
docker exec "$CONTAINER_NAME" /usr/bin/mysqldump -u "$DB_USER" -p"$DB_PASSWORD" --databases "$DB_NAME" --no-tablespaces > "$FILEPATH"
|
|
|
|
# Check if file size is too small (e.g., < 1KB), which usually indicates an empty dump or error
|
|
FILE_SIZE=$(stat -c%s "$FILEPATH" 2>/dev/null || stat -f%z "$FILEPATH")
|
|
if [ "$FILE_SIZE" -lt 1024 ]; then
|
|
echo "Error: Backup file is too small ($FILE_SIZE bytes). Dump might have failed."
|
|
cat "$FILEPATH" # Print content to log for debugging
|
|
exit 1
|
|
fi
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "[$(date)] Database dump successful: ${FILEPATH}"
|
|
|
|
# 2. Compress the backup
|
|
gzip "$FILEPATH"
|
|
echo "[$(date)] Compression successful: ${GZ_FILEPATH}"
|
|
|
|
# 3. Upload to MinIO using the Go uploader
|
|
if [ -f "$UPLOADER_PATH" ]; then
|
|
echo "[$(date)] Uploading to object storage..."
|
|
chmod +x "$UPLOADER_PATH"
|
|
"$UPLOADER_PATH" -file "$GZ_FILEPATH" -bucket backup
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "[$(date)] Upload successful."
|
|
else
|
|
echo "[$(date)] Upload failed."
|
|
fi
|
|
else
|
|
echo "Warning: Uploader binary not found at $UPLOADER_PATH. Skipping upload."
|
|
fi
|
|
|
|
# 4. Clean up old local backups (optional)
|
|
find "$BACKUP_DIR" -name "mysql_backup_*.sql.gz" -mtime +$RETENTION_DAYS -delete
|
|
echo "[$(date)] Cleaned up local backups older than $RETENTION_DAYS days."
|
|
|
|
else
|
|
echo "Error: Database dump failed!"
|
|
# Clean up empty file if dump failed
|
|
if [ -f "$FILEPATH" ]; then
|
|
rm "$FILEPATH"
|
|
fi
|
|
exit 1
|
|
fi
|
|
|
|
echo "[$(date)] Backup process completed."
|