update state file correctly

This commit is contained in:
dave 2023-10-01 11:48:05 -07:00
parent 85a34d4e57
commit 168231779a
2 changed files with 3 additions and 2 deletions

View File

@ -4,4 +4,4 @@ CFG_DIR = os.environ.get("RESTICBACKUP_CONFIG_DIR", "/etc/resticbackup.d")
RESTIC_BIN = os.environ.get("RESTICBACKUP_RESTIC_BIN_PATH", "restic")
__version__ = "0.0.8"
__version__ = "0.0.9"

View File

@ -164,7 +164,8 @@ def update_statefile(path, success):
"success": bool(success),
}
)
state = state[0:10]
state.sort(key=lambda x: x["time"])
state = state[-10:]
with open(path, "w") as f:
json.dump(state, f, indent=4, sort_keys=True)