umfassende updates
This commit is contained in:
parent
3331f08091
commit
50cd802d33
16 changed files with 441 additions and 78 deletions
|
|
@ -192,6 +192,11 @@ def main():
|
|||
action="store_true",
|
||||
help="DB-Sync überspringen (keine Daten in die entfernte DB einspielen).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--db-only",
|
||||
action="store_true",
|
||||
help="Nur den DB-Sync ausführen, ohne Dateien per FTP hochzuladen.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not os.path.isfile(CRED_FILE):
|
||||
|
|
@ -211,6 +216,10 @@ def main():
|
|||
else:
|
||||
sync_database(creds)
|
||||
|
||||
if args.db_only:
|
||||
print("\nDB-Sync abgeschlossen (ohne Upload) ->", APP_URL)
|
||||
return
|
||||
|
||||
ftp = FTP()
|
||||
ftp.connect(FTP_HOST, FTP_PORT)
|
||||
ftp.login(creds["ftp_user"], creds["ftp_pw"])
|
||||
|
|
|
|||
47
tools/sync_live_to_test.sh
Executable file
47
tools/sync_live_to_test.sh
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Synchronisiert alle 5 Minuten die Legacy-Live-DB in das Testsystem.
|
||||
#
|
||||
# Ablauf pro Zyklus:
|
||||
# 1. Dump der Legacy-Live-DB erzeugen (dump_pfosten.py)
|
||||
# 2. Dump lokal importieren und nach tippspiel2027 migrieren (import_from_dump.sh)
|
||||
# 3. Nur den DB-Teil von deploy_test.py ausführen (--db-only, kein FTP-Upload)
|
||||
#
|
||||
# Aufruf:
|
||||
# ./sync_live_to_test.sh Endlosschleife (alle 5 Minuten)
|
||||
# ./sync_live_to_test.sh --once genau ein Durchlauf
|
||||
#
|
||||
# Intervall über SYNC_INTERVAL (Sekunden) überschreibbar, z.B.:
|
||||
# SYNC_INTERVAL=60 ./sync_live_to_test.sh
|
||||
|
||||
TOOLS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DUMP_SCRIPT="/home/torsten/repos/tippspiel/tools/dump_pfosten.py"
|
||||
IMPORT_SCRIPT="$TOOLS_DIR/import_from_dump.sh"
|
||||
DEPLOY_SCRIPT="$TOOLS_DIR/deploy_test.py"
|
||||
INTERVAL="${SYNC_INTERVAL:-300}"
|
||||
|
||||
run_once() {
|
||||
echo "[$(date '+%F %T')] Dump der Legacy-Live-DB..."
|
||||
python3 "$DUMP_SCRIPT"
|
||||
|
||||
echo "[$(date '+%F %T')] Import + Migration..."
|
||||
"$IMPORT_SCRIPT"
|
||||
|
||||
echo "[$(date '+%F %T')] DB-Sync zum Testsystem..."
|
||||
python3 "$DEPLOY_SCRIPT" --db-only
|
||||
|
||||
echo "[$(date '+%F %T')] Zyklus abgeschlossen."
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "--once" ]]; then
|
||||
run_once
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Starte Sync-Schleife (alle ${INTERVAL}s). Beenden mit Strg+C."
|
||||
while true; do
|
||||
run_once || true
|
||||
echo "Warte ${INTERVAL}s..."
|
||||
sleep "$INTERVAL"
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue