py-pve-cloud-backup 0.5.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,68 @@
1
+ import paramiko
2
+ import logging
3
+ from pve_cloud_backup.fetcher.net import archive
4
+ import os
5
+
6
+ logger = logging.getLogger("fetcher")
7
+
8
+
9
+ async def backup_patroni(backup_addr, timestamp, proxmox, stack_fqdn, pkey):
10
+ logger.info("looking for " + stack_fqdn)
11
+
12
+ patroni_member = None
13
+
14
+ for node in proxmox.nodes.get():
15
+ node_name = node["node"]
16
+ logger.info("collecting node " + node_name)
17
+
18
+ if node["status"] == "offline":
19
+ logger.info(f"skipping offline node {node_name}")
20
+ continue
21
+
22
+ for lxc in proxmox.nodes(node_name).lxc.get():
23
+ if "tags" not in lxc:
24
+ continue # non stack vm
25
+
26
+ if stack_fqdn in lxc["tags"]:
27
+ patroni_member = lxc
28
+ break
29
+
30
+ if not patroni_member:
31
+ raise Exception("Couldnt find a patroni member for the specified stack " + stack_fqdn)
32
+
33
+ stack_apex = ".".join(stack_fqdn.split(".")[1:])
34
+
35
+ ssh = paramiko.SSHClient()
36
+ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
37
+
38
+ logger.info("connecting to patroni member " + lxc["name"] + "." + stack_apex)
39
+ ssh.connect(lxc["name"] + "." + stack_apex, username="root", pkey=pkey)
40
+
41
+ # create pg pass file
42
+ _, stdout, _ = ssh.exec_command("echo '*:*:*:*:" + os.getenv("PATRONI_PASS") + "' > ~/.pgpass && chmod 600 ~/.pgpass")
43
+
44
+ def chunk_generator():
45
+ stdin, stdout, stderr = ssh.exec_command(
46
+ "pg_dumpall -h 127.0.0.1 -p 5432 -U postgres --no-role-passwords",
47
+ bufsize=0
48
+ )
49
+ chunk_size = 4 * 1024 * 1024
50
+ channel = stdout.channel
51
+
52
+ while not channel.exit_status_ready() or channel.recv_ready():
53
+ data = channel.recv(chunk_size)
54
+ if not data:
55
+ continue
56
+ yield data
57
+
58
+ request_dict = {
59
+ "borg_archive_type": "postgres",
60
+ "archive_name": "patroni_dump.db",
61
+ "timestamp": timestamp,
62
+ "stdin_name": "patroni_dump.db"
63
+ }
64
+
65
+ await archive(backup_addr, request_dict, chunk_generator)
66
+
67
+ # delete the password file again
68
+ _, stdout, _ = ssh.exec_command("rm ~/.pgpass")
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-pve-cloud-backup
3
+ Version: 0.5.11
4
+ Author-email: Tobias Huebner <tobias.huebner@vmzberlin.com>
5
+ License-Expression: GPL-3.0-or-later
6
+ Requires-Dist: proxmoxer==2.2.0
7
+ Requires-Dist: kubernetes==34.1.0
8
+ Requires-Dist: PyYAML==6.0.2
9
+ Requires-Dist: paramiko==4.0.0
10
+ Requires-Dist: requests==2.32.5
11
+ Requires-Dist: zstandard==0.25.0
12
+ Requires-Dist: tinydb==4.8.2
@@ -0,0 +1,15 @@
1
+ pve_cloud_backup/_version.py,sha256=xFez9dUQrcuZqZRWuEIsCbMskoR-Ke1_uUZ51Kyt1tw,23
2
+ pve_cloud_backup/daemon/bdd.py,sha256=g7DhYvFjDjeBOjd0E4v3MgNMQ9Fk8cw2xfJVhRjsxX0,5390
3
+ pve_cloud_backup/daemon/brctl.py,sha256=ZrO5qV29J4_o7GatxBSQZUbYMlFX71S9zfKuLJTzyLM,7493
4
+ pve_cloud_backup/daemon/shared.py,sha256=5S39_pkw9WXEo9sBPAgY5L-qp99cmo5dL32-nhXMSAA,17204
5
+ pve_cloud_backup/fetcher/funcs.py,sha256=30Kziuk3QRxhHrosqK0gQLLL7gi8mwEqux44tQpk4h0,13673
6
+ pve_cloud_backup/fetcher/git.py,sha256=ryV21HHs_Q5hrVM1hZ51LJLXHVMgh6hupn0v4xM3KZg,1107
7
+ pve_cloud_backup/fetcher/main.py,sha256=XTUcn6tSHgqAGlmlPstkwz3hFHIk2cpbf9hJFmK5kao,2846
8
+ pve_cloud_backup/fetcher/net.py,sha256=MVCqdb3ZFI8gbeUB2NrWrkykwuKAFOznH1gqtqyT4OE,3768
9
+ pve_cloud_backup/fetcher/nextcloud.py,sha256=81rNSejD_pIfyng6TiuAut09AvZbgr57blpVc1hJmU4,1191
10
+ pve_cloud_backup/fetcher/patroni.py,sha256=ZAJmbiY9fqIYMLOgxOAa3s7odfzI2ecQgWdiy18M29U,1953
11
+ py_pve_cloud_backup-0.5.11.dist-info/METADATA,sha256=mvZujH5RUTC2DJApcN-nYzlDhnoBYtM9ULeAjQk4pmY,381
12
+ py_pve_cloud_backup-0.5.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ py_pve_cloud_backup-0.5.11.dist-info/entry_points.txt,sha256=0QG_j55-wiJS1_vLNsjju0Ly9ycpBSTOhUF-PlWizOM,148
14
+ py_pve_cloud_backup-0.5.11.dist-info/top_level.txt,sha256=w9KT8Yar3s02YhN-DBabObecqlIub36RT6lLZ4iG9dE,17
15
+ py_pve_cloud_backup-0.5.11.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ brctl = pve_cloud_backup.daemon.brctl:main
3
+ daemon = pve_cloud_backup.daemon.bdd:main
4
+ fetcher = pve_cloud_backup.fetcher.main:main
@@ -0,0 +1 @@
1
+ pve_cloud_backup