Skip to content
Snippets Groups Projects
Commit 7f9ab1dc authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

fix(test): handle more backup use cases

parent 59e03ecf
No related branches found
No related tags found
No related merge requests found
......@@ -73,8 +73,10 @@ def test_last_backup_is_recent(server: str) -> bool:
# set backup potential directories path
paths = [
"/backup/{}/home/latest".format(client),
"/backup/data/latest",
"/backup/{}/".format(client),
"/backup/data/",
"/backup/nas*/",
"/backup/ms*/",
]
# test each possible path
......@@ -82,14 +84,16 @@ def test_last_backup_is_recent(server: str) -> bool:
# build and run commands
find = "find -L {} {} {} {} {}".format(
path,
"-maxdepth 0",
"-maxdepth 1",
"-xtype l",
"-name latest",
"-exec realpath {} +" # must always be last arg
)
cmd = "ssh -o StrictHostKeyChecking=no {} '{}'".format(server, find)
status, out = subprocess.getstatusoutput(cmd)
if status == 0:
# TODO: check all backups found instead of only the last of the list
# maybe do a `split()` and `if len(lst) > 1`…
if status == 0 and out != "":
# get directory name and convert to datetime
last = out.strip().split("/")[-1]
date = datetime.strptime(last, "%Y-%m-%d-%H%M%S")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment