add logger for borg

This commit is contained in:
2025-09-15 16:56:38 +02:00
parent fc6f120c53
commit 67a7e2dacf

View File

@@ -5,6 +5,9 @@ from io import StringIO
from pathlib import Path
import paramiko
import structlog
logger = structlog.get_logger(__name__)
@contextmanager
@@ -41,14 +44,16 @@ def list_repos(client, parent) -> Iterator[str]:
sftp = client.open_sftp()
for path in paths:
name = Path(path).parent.name
logger.info("Opening path", name=name)
with sftp.open(path, "r") as f:
try:
content = f.read().decode()
config = ConfigParser()
config.read_file(StringIO(content))
config.get("repository", "version")
yield Path(path).parent.name
yield name
except Exception as e:
print(f"Not a borg repository: {e}")
logger.warning("Not a borg repository!", e=e)
sftp.close()