Files
novalon-website/scripts/deployment/restore.sh
T
张翔 498bb3a3c8 refactor: reorganize project structure and improve code quality
- Move CI/CD configs to config/ci/ directory
- Reorganize scripts into categorized directories (deployment, monitoring, testing, utils)
- Consolidate documentation into docs/ directory with proper structure
- Update linting and testing configurations
- Remove obsolete test reports and performance summaries
- Add new documentation for code quality tools and contact form security
- Improve project organization and maintainability
- Fix lint-staged config to only lint JS/TS files
- Disable react/react-in-jsx-scope rule for Next.js compatibility
- Ignore scripts and test config directories in ESLint
2026-03-24 13:38:58 +08:00

70 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# 恢复脚本
# 用法: ./scripts/restore.sh <backup_file.tar.gz>
set -e
if [ -z "$1" ]; then
echo "错误: 请指定备份文件"
echo "用法: ./scripts/restore.sh <backup_file.tar.gz>"
exit 1
fi
BACKUP_FILE="$1"
if [ ! -f "$BACKUP_FILE" ]; then
echo "错误: 备份文件不存在: $BACKUP_FILE"
exit 1
fi
echo "警告: 此操作将覆盖当前数据!"
read -p "确认继续? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo "操作已取消"
exit 0
fi
# 创建临时目录
TEMP_DIR="./temp_restore_$(date +%s)"
mkdir -p "$TEMP_DIR"
echo "解压备份..."
tar -xzf "$BACKUP_FILE" -C "$TEMP_DIR"
# 获取备份目录名
BACKUP_DIR_NAME=$(ls "$TEMP_DIR")
BACKUP_PATH="$TEMP_DIR/$BACKUP_DIR_NAME"
# 恢复数据库
if [ -f "$BACKUP_PATH/database.db" ]; then
echo "恢复数据库..."
cp "$BACKUP_PATH/database.db" ./data/prod.db
else
echo "警告: 备份中没有数据库文件"
fi
# 恢复上传文件
if [ -d "$BACKUP_PATH/uploads" ]; then
echo "恢复上传文件..."
rm -rf ./uploads/*
cp -r "$BACKUP_PATH/uploads"/* ./uploads/ 2>/dev/null || true
else
echo "警告: 备份中没有uploads目录"
fi
# 恢复配置
if [ -f "$BACKUP_PATH/.env.production" ]; then
echo "恢复配置..."
cp "$BACKUP_PATH/.env.production" ./.env.production
else
echo "警告: 备份中没有配置文件"
fi
# 清理临时文件
rm -rf "$TEMP_DIR"
echo "恢复完成!"
echo "请重启应用以使更改生效"