Files
bf-infra/routeros/restore-core.py
Christoph Emsenhuber d281a0f36f TP15: CRS326-Core als L3-Router aktiviert
- crs326-core nimmt Routing/DHCP/DNS/NAT/WAN/WireGuard von ap1 ueber.
- L2-Portplan korrigiert (ap1 #15, Arris WAN #16, branch #8, Sonos #2/3/5/6,
  IoT #14, VLAN10-Access #11, VLAN1-Hybrid #3/7/9/10/12/17-24).
- Backup-RSC gefixt (ether3-24 disabled) und via fixed-RSC eingespielt.
- Gestagede L3-Config enabled in einem Rutsch.
- Falsche statische Default-Route 0.0.0.0/0 -> 10.40.41.1 entfernt,
  WAN-DHCP via 90.146.33.177/24 aktiv.
- SFP-Ports bleiben disabled (Stromersparnis).
- ap1 ist L3-stillgelegt und wird in naechster Session reiner AP.

Backup-Dateien (*.backup) und leases-export.json bleiben lokal.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-07 22:39:29 +02:00

80 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""Stelle das crs326-core Backup vom Cutover-Stand wieder her.
Creds aus ~/.claude.json (mikromcp-env, CRS326_CORE_*).
Backup-Datei wird per SCP hochgeladen und /system backup load ausgefuehrt.
"""
import json
import pathlib
import subprocess
import sys
CORE_IP = "192.168.88.1"
BACKUP = "crs326-core-pre-cutover-20260806-073712.backup"
CLAUDE_JSON = pathlib.Path.home() / ".claude.json"
OUT_DIR = pathlib.Path(__file__).resolve().parent
def load_core_creds():
cfg = json.loads(CLAUDE_JSON.read_text())
env = cfg.get("mcpServers", {}).get("mikromcp", {}).get("env", {})
user = env.get("CRS326_CORE_USER") or env.get("ROUTER_USER")
pw = env.get("CRS326_CORE_PASS") or env.get("ROUTER_PASS")
if not user or not pw:
raise SystemExit("CRS326_CORE_USER/PASS nicht in ~/.claude.json mikromcp.env gefunden")
return user, pw
def ssh_cmd(user, pw, remote_command):
return [
"sshpass", "-p", pw,
"ssh",
"-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "PubkeyAuthentication=no",
f"{user}@{CORE_IP}",
remote_command,
]
def scp_cmd(user, pw, local_file, remote_file):
return [
"sshpass", "-p", pw,
"scp",
"-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "PubkeyAuthentication=no",
str(local_file),
f"{user}@{CORE_IP}:{remote_file}",
]
def run_silent(cmd, pw):
r = subprocess.run(cmd, capture_output=True, text=True)
if r.returncode != 0:
out = (r.stdout + r.stderr).replace(pw, "***")
raise SystemExit(f"Befehl fehlgeschlagen (rc={r.returncode}):\n{out}")
return r
def main():
local_backup = OUT_DIR / BACKUP
if not local_backup.exists():
raise SystemExit(f"{local_backup} fehlt")
user, pw = load_core_creds()
print(f"crs326-core Restore via SSH {user}@{CORE_IP}")
print(f" Lade {BACKUP} hoch ...")
run_silent(scp_cmd(user, pw, local_backup, BACKUP), pw)
print(f" Spiele Backup zurueck ...")
run_silent(ssh_cmd(user, pw, f'/system backup load name="{BACKUP}" password=""'), pw)
print(" Backup geladen, Router rebootet.")
print(" Warte auf Wiederverbindung an 10.40.41.211 ...")
if __name__ == "__main__":
main()