fix: update import/export to use params

This commit is contained in:
uprightbass360
2025-10-27 17:50:23 -04:00
parent 8225526eed
commit 9255ac82d8
3 changed files with 65 additions and 64 deletions

View File

@@ -2,17 +2,17 @@
# Export auth and character databases to ExportBackup_<timestamp>/
set -euo pipefail
MYSQL_PW="${MYSQL_ROOT_PASSWORD}"
DB_AUTH="${DB_AUTH_NAME}"
DB_CHAR="${DB_CHARACTERS_NAME}"
usage(){
cat <<EOF
Usage: ./backup-export.sh [output_dir]
Usage: ./backup-export.sh [output_dir] <mysql_password> <auth_db> <characters_db>
Creates a timestamped backup of the auth and character databases.
If output_dir is provided, places the timestamped folder inside it
(default: .).
Arguments:
[output_dir] Output directory (default: .)
<mysql_password> MySQL root password (required)
<auth_db> Auth database name (required)
<characters_db> Characters database name (required)
Outputs:
ExportBackup_YYYYMMDD_HHMMSS/
@@ -28,6 +28,26 @@ case "${1:-}" in
-h|--help) usage; exit 0;;
esac
MYSQL_PW="$2"
DB_AUTH="$3"
DB_CHAR="$4"
# Check if required parameters are provided
if [[ -z "$MYSQL_PW" ]]; then
echo "Error: MySQL password required as second argument." >&2
exit 1
fi
if [[ -z "$DB_AUTH" ]]; then
echo "Error: Auth database name required as third argument." >&2
exit 1
fi
if [[ -z "$DB_CHAR" ]]; then
echo "Error: Characters database name required as fourth argument." >&2
exit 1
fi
DEST_PARENT="${1:-.}"
TIMESTAMP="$(date +%Y%m%d_%H%M%S)"
DEST_DIR="${DEST_PARENT%/}/ExportBackup_${TIMESTAMP}"