mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-07-17 06:05:13 +00:00
feat(backup)!: opt-in hard restart and mandatory backups-dir
Rename --docker-compose-hard-restart-required to --hard-compose-restart and change its default from ["mailu"] to [] (nargs="*"): the compose down/up is now opt-in, so compose hosts pass "mailu" while swarm hosts, where the dir is a stack whose overlay network collides with compose up, pass nothing. Make --backups-dir mandatory (no /var/lib/backup/ default) so a run can never silently target the wrong backup root. BREAKING CHANGE: the old flag name is removed, the implicit mailu default is gone, and --backups-dir must be passed explicitly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -251,5 +251,61 @@ class TestCompose(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class HardRestartArgTests(unittest.TestCase):
|
||||
"""The hard-restart list defaults to empty (no compose down/up); callers
|
||||
opt in per dir, e.g. compose hosts pass 'mailu' while swarm hosts, where
|
||||
the dir is a stack whose overlay network collides with compose up, pass
|
||||
nothing."""
|
||||
|
||||
def _parse(self, extra: List[str]):
|
||||
import sys
|
||||
|
||||
from baudolo.backup import cli
|
||||
|
||||
argv = [
|
||||
"baudolo",
|
||||
"--compose-dir",
|
||||
"/tmp",
|
||||
"--backups-dir",
|
||||
"/tmp/backup",
|
||||
"--database-containers",
|
||||
"postgres",
|
||||
"--images-no-stop-required",
|
||||
"redis",
|
||||
*extra,
|
||||
]
|
||||
with patch.object(sys, "argv", argv):
|
||||
return cli.parse_args()
|
||||
|
||||
def test_default_is_empty(self) -> None:
|
||||
args = self._parse([])
|
||||
self.assertEqual(args.hard_compose_restart, [])
|
||||
|
||||
def test_empty_flag_stays_empty(self) -> None:
|
||||
args = self._parse(["--hard-compose-restart"])
|
||||
self.assertEqual(args.hard_compose_restart, [])
|
||||
|
||||
def test_explicit_names_preserved(self) -> None:
|
||||
args = self._parse(["--hard-compose-restart", "mailu", "foo"])
|
||||
self.assertEqual(args.hard_compose_restart, ["mailu", "foo"])
|
||||
|
||||
def test_backups_dir_is_required(self) -> None:
|
||||
import sys
|
||||
|
||||
from baudolo.backup import cli
|
||||
|
||||
argv = [
|
||||
"baudolo",
|
||||
"--compose-dir",
|
||||
"/tmp",
|
||||
"--database-containers",
|
||||
"postgres",
|
||||
"--images-no-stop-required",
|
||||
"redis",
|
||||
]
|
||||
with patch.object(sys, "argv", argv), self.assertRaises(SystemExit):
|
||||
cli.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
|
||||
Reference in New Issue
Block a user