From 3ba75764e3e896b035a2da0c417013faee3fed52 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 10 Nov 2025 14:07:40 +0100 Subject: [PATCH] never overwrite old backups, create new ones always --- changedetectionio/store.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/changedetectionio/store.py b/changedetectionio/store.py index 8ca283c7f..35ed9f2a7 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -770,7 +770,14 @@ class ChangeDetectionStore: logger.critical(f"Applying update_{update_n}") # Wont exist on fresh installs if os.path.exists(self.json_store_path): - shutil.copyfile(self.json_store_path, os.path.join(self.datastore_path, f"url-watches-before-{update_n}.json")) + i = 0 + while True: + i+=1 + dest = os.path.join(self.datastore_path, f"url-watches-before-{update_n}-{i}.json") + if not os.path.exists(dest): + logger.debug(f"Copying url-watches.json DB to '{dest}' backup.") + shutil.copyfile(self.json_store_path, dest) + break try: update_method = getattr(self, f"update_{update_n}")()