|
|
|
@ -5,6 +5,8 @@ from typing import Union |
|
|
|
|
|
|
|
import paramiko |
|
|
|
|
|
|
|
from openwrt_backup.config import HOSTNAME, NUMBER |
|
|
|
|
|
|
|
|
|
|
|
def client_from_config(name: str, ssh_config_root: Path): |
|
|
|
"""Create a client from a Host entry in the .ssh/config file""" |
|
|
|
@ -59,10 +61,10 @@ def get_next_number(backup_path: Path, hostname): |
|
|
|
f_names = (path.name for path in backup_path.glob("*.tar.gz")) |
|
|
|
f_names_fields = map(lambda s: s.split("__"), f_names) |
|
|
|
f_names_fields_filtered = filter( |
|
|
|
lambda fields: fields[1] == hostname, f_names_fields |
|
|
|
lambda fields: fields[HOSTNAME] == hostname, f_names_fields |
|
|
|
) |
|
|
|
try: |
|
|
|
return max(int(fields[0]) for fields in f_names_fields_filtered) + 1 |
|
|
|
return max(int(fields[NUMBER]) for fields in f_names_fields_filtered) + 1 |
|
|
|
except ValueError: |
|
|
|
return 0 |
|
|
|
|
|
|
|
|