|
|
@ -13,8 +13,8 @@ from openwrt_backup.config import CONFIG_DATA # noqa |
|
|
from openwrt_backup.prune import get_all_but_last_n |
|
|
from openwrt_backup.prune import get_all_but_last_n |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def do_prune(dest_path: Path, n: int, dry): |
|
|
|
|
|
to_delete = get_all_but_last_n(dest_path, n) |
|
|
|
|
|
|
|
|
def do_prune(dest_path: Path, n: int, dry, hostname=None): |
|
|
|
|
|
to_delete = get_all_but_last_n(dest_path, n, hostname) |
|
|
for f in to_delete: |
|
|
for f in to_delete: |
|
|
if dry: |
|
|
if dry: |
|
|
print(f"Deleting: {f}") |
|
|
print(f"Deleting: {f}") |
|
|
@ -42,6 +42,7 @@ def do_backup( |
|
|
else: |
|
|
else: |
|
|
backup_on_remote = make_backup_on_remote(client, tmp_path) |
|
|
backup_on_remote = make_backup_on_remote(client, tmp_path) |
|
|
retrieve_backup_on_remote(client, backup_on_remote, dest) |
|
|
retrieve_backup_on_remote(client, backup_on_remote, dest) |
|
|
|
|
|
return hostname |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
def main(): |
|
|
@ -86,7 +87,7 @@ def main(): |
|
|
print(toml.dumps(CONFIG_DATA)) |
|
|
print(toml.dumps(CONFIG_DATA)) |
|
|
exit(0) |
|
|
exit(0) |
|
|
|
|
|
|
|
|
do_backup( |
|
|
|
|
|
|
|
|
hostname = do_backup( |
|
|
args.name, |
|
|
args.name, |
|
|
Path(CONFIG_DATA["ssh"]["root"]).expanduser(), |
|
|
Path(CONFIG_DATA["ssh"]["root"]).expanduser(), |
|
|
Path(CONFIG_DATA["backup"]["path"]).expanduser(), |
|
|
Path(CONFIG_DATA["backup"]["path"]).expanduser(), |
|
|
@ -99,4 +100,5 @@ def main(): |
|
|
Path(CONFIG_DATA["backup"]["path"]).expanduser(), |
|
|
Path(CONFIG_DATA["backup"]["path"]).expanduser(), |
|
|
CONFIG_DATA["backup"]["keep"], |
|
|
CONFIG_DATA["backup"]["keep"], |
|
|
args.dry, |
|
|
args.dry, |
|
|
|
|
|
hostname, |
|
|
) |
|
|
) |