chore: remove unused file
This commit is contained in:
37
scripts/sync_backups_to_nas.py
Normal file
37
scripts/sync_backups_to_nas.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import paramiko
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
nodes = [
|
||||
("aerodrome", "140.44.4.11", ["authentik_clean.sql.gz", "awx_clean.sql.gz"]),
|
||||
("spaceport", "140.44.4.41", ["gitea_clean.sql.gz", "zabbix_clean.sql.gz"])
|
||||
]
|
||||
|
||||
for name, ip, files in nodes:
|
||||
print(f"[{name.upper()}] Mounting NAS and copying backups...")
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(ip, username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
setup_cmd = """
|
||||
mkdir -p /mnt/nas_backup
|
||||
mount -t nfs -o vers=4 14.10.10.71:/volume1/docker /mnt/nas_backup || mount -t nfs 14.10.10.71:/volume1/docker /mnt/nas_backup
|
||||
mkdir -p /mnt/nas_backup/backups/databases
|
||||
"""
|
||||
stdin, stdout, stderr = ssh.exec_command(setup_cmd)
|
||||
stdout.channel.recv_exit_status()
|
||||
|
||||
for f in files:
|
||||
cp_cmd = f"cp /var/backups/{f} /mnt/nas_backup/backups/databases/ && ls -lh /mnt/nas_backup/backups/databases/{f}"
|
||||
stdin, stdout, stderr = ssh.exec_command(cp_cmd)
|
||||
stdout.channel.recv_exit_status()
|
||||
print(f" Saved to NAS: {stdout.read().decode().strip()}")
|
||||
|
||||
umount_cmd = "umount -f /mnt/nas_backup || true"
|
||||
stdin, stdout, stderr = ssh.exec_command(umount_cmd)
|
||||
stdout.channel.recv_exit_status()
|
||||
ssh.close()
|
||||
|
||||
print("All database backups verified mirrored to Synology NAS (14.10.10.71).")
|
||||
|
||||
Reference in New Issue
Block a user