From 9c7586c7c3a235672ec6490d1a8bc44a222ce5d1 Mon Sep 17 00:00:00 2001 From: Colin Wilk Date: Tue, 1 Sep 2026 21:01:05 +0200 Subject: Add borg prune and compact jobs Run repository retention either after a successful backup or from a dedicated systemd timer. Clean up script generation with templates and expand molecule test coverage. BREAKING CHANGE: Aggregate backup scripts are no longer managed, and state=preset now requires at least one readable included directory. --- molecule/delete/tests/test_delete.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'molecule/delete/tests/test_delete.py') diff --git a/molecule/delete/tests/test_delete.py b/molecule/delete/tests/test_delete.py index 4c0d859..3fc3189 100644 --- a/molecule/delete/tests/test_delete.py +++ b/molecule/delete/tests/test_delete.py @@ -37,6 +37,16 @@ class TestSingleRepoDelete: assert not timer.exists assert not service.exists + def test_prune_systemd_units_removed(self, host): + hostname = host.backend.get_hostname() + if hostname != "borg-client-single-delete": + return + + timer = host.file("/etc/systemd/system/borg_prune@single-backup.timer") + service = host.file("/etc/systemd/system/borg_prune@single-backup.service") + assert not timer.exists + assert not service.exists + def test_backup_scripts_removed(self, host): hostname = host.backend.get_hostname() if hostname != "borg-client-single-delete": @@ -47,6 +57,16 @@ class TestSingleRepoDelete: assert not repo_script.exists assert not base_script.exists + def test_prune_scripts_removed(self, host): + hostname = host.backend.get_hostname() + if hostname != "borg-client-single-delete": + return + + repo_script = host.file("/usr/local/bin/run_borg_prune@single-backup") + base_script = host.file("/usr/local/bin/run_borg_prune") + assert not repo_script.exists + assert not base_script.exists + def test_shared_ssh_key_kept(self, host): hostname = host.backend.get_hostname() if hostname != "borg-client-single-delete": @@ -98,17 +118,12 @@ class TestMultiInstanceDelete: assert service.exists assert script.exists - def test_base_script_keeps_only_remaining_block(self, host): + def test_aggregate_script_is_absent(self, host): hostname = host.backend.get_hostname() if hostname != "borg-client-multi-delete": return - base_script = host.file("/usr/local/bin/run_borg_backup") - assert base_script.exists - content = base_script.content_string - assert "/opt/borg/multi-repo-b" in content - assert "/opt/borg/multi-repo-a" not in content - assert content.count("borg create") == 1 + assert not host.file("/usr/local/bin/run_borg_backup").exists def test_shared_ssh_key_kept(self, host): hostname = host.backend.get_hostname() @@ -168,13 +183,10 @@ class TestPerRepoKeyDelete: timer = host.file("/etc/systemd/system/borg_backup@per-repo-b.timer") service = host.file("/etc/systemd/system/borg_backup@per-repo-b.service") script = host.file("/usr/local/bin/run_borg_backup@per-repo-b") - base_script = host.file("/usr/local/bin/run_borg_backup") assert timer.exists assert service.exists assert script.exists - assert base_script.exists - assert "/opt/borg/per-repo-b" in base_script.content_string - assert "/opt/borg/per-repo-a" not in base_script.content_string + assert not host.file("/usr/local/bin/run_borg_backup").exists def test_per_repo_ssh_key_removed(self, host): hostname = host.backend.get_hostname() -- cgit v1.2.3