16 lines
688 B
Python
16 lines
688 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
cmd = "kubectl exec -n infra authentik-postgresql-0 -- sh -c 'PGPASSWORD=$(cat /opt/bitnami/postgresql/secrets/password) pg_dump -U authentik authentik' | gzip > /var/backups/authentik_clean.sql.gz"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
|
print("STDERR:", stderr.read().decode())
|
|
_, out, _ = ssh.exec_command("ls -lh /var/backups/authentik_clean.sql.gz")
|
|
print("RESULT:", out.read().decode().strip())
|
|
ssh.close()
|
|
|