import paramiko import sys import time sys.stdout.reconfigure(encoding='utf-8') ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('140.44.4.41', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) def run(cmd): print(f"\n=== {cmd} ===") _, out, err = ssh.exec_command(cmd) res = out.read().decode('utf-8', errors='replace').strip() if res: print(res) e = err.read().decode('utf-8', errors='replace').strip() if e: print("ERR:", e) print("[1] Creating backup directory on Spaceport master...") run("mkdir -p /var/backups/coder_home") print("[2] Getting current Coder pod name...") _, out, _ = ssh.exec_command("kubectl get pod -n infrastructure -l app.kubernetes.io/name=coder -o jsonpath='{.items[0].metadata.name}'") pod_name = out.read().decode().strip() print(f"Active Coder pod: {pod_name}") print("[3] Copying /home/coder from active pod to /var/backups/coder_home...") run(f"kubectl exec -n infrastructure {pod_name} -- tar -czf /tmp/coder_backup.tar.gz -C /home/coder .") run(f"kubectl cp infrastructure/{pod_name}:/tmp/coder_backup.tar.gz /var/backups/coder_home/coder_backup.tar.gz") run("ls -lh /var/backups/coder_home/coder_backup.tar.gz") print("[4] Creating PersistentVolumeClaim 'coder-data' (10Gi, Longhorn)...") pvc_yaml = """cat <