backup import/export docs

This commit is contained in:
Deckard
2025-10-19 20:29:59 -04:00
parent b259f2c61d
commit a67294aecd
3 changed files with 17 additions and 2 deletions

55
backup-export.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
# Export auth and character databases to ExportBackup_<timestamp>/
set -euo pipefail
MYSQL_PW="${MYSQL_ROOT_PASSWORD:-azerothcore123}"
DB_AUTH="${DB_AUTH_NAME:-acore_auth}"
DB_CHAR="${DB_CHARACTERS_NAME:-acore_characters}"
usage(){
cat <<EOF
Usage: ./backup-export.sh [output_dir]
Creates a timestamped backup of the auth and character databases.
If output_dir is provided, places the timestamped folder inside it
(default: .).
Outputs:
ExportBackup_YYYYMMDD_HHMMSS/
acore_auth.sql.gz
acore_characters.sql.gz
manifest.json
Services stay online; backup uses mysqldump.
EOF
}
case "${1:-}" in
-h|--help) usage; exit 0;;
esac
DEST_PARENT="${1:-.}"
TIMESTAMP="$(date +%Y%m%d_%H%M%S)"
DEST_DIR="${DEST_PARENT%/}/ExportBackup_${TIMESTAMP}"
mkdir -p "$DEST_DIR"
dump_db(){
local db="$1" outfile="$2"
echo "Dumping $db -> $outfile"
docker exec ac-mysql mysqldump -uroot -p"$MYSQL_PW" "$db" | gzip > "$outfile"
}
dump_db "$DB_AUTH" "$DEST_DIR/acore_auth.sql.gz"
dump_db "$DB_CHAR" "$DEST_DIR/acore_characters.sql.gz"
cat > "$DEST_DIR/manifest.json" <<JSON
{
"generated_at": "$(date --iso-8601=seconds)",
"databases": {
"auth": "$DB_AUTH",
"characters": "$DB_CHAR"
}
}
JSON
echo "Backups saved under $DEST_DIR"