From 3e817d4e4456cc4b1058e3a0ef72f8690a37e8ed Mon Sep 17 00:00:00 2001 From: Filipp Balakin Date: Mon, 26 Apr 2021 05:02:30 +0300 Subject: [PATCH] keep only last 3 backups... --- update_DBM.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/update_DBM.py b/update_DBM.py index 4d3d22c..720ed94 100644 --- a/update_DBM.py +++ b/update_DBM.py @@ -60,6 +60,16 @@ def map_directory(repo_name, folder_glob): print("BACKUP: Backup finished") + backups_folder = Path(f"./repositories/{repo_name}-backups/") + print("BACKUP: Cleaning older backups if they exist... Keeping only last 3") + + sorted_backups = [entry for entry in sorted(backups_folder.iterdir(), key=lambda x: x.name, reverse=True)] + for path in sorted_backups[3:]: + print(f"BACKUP: removing {path}") + shutil.rmtree(path) + + print("BACKUP: Backup clean complete.") + return addons print("UPDATER: directory incorrect, PLEASE place in folder with Wow.exe (WoW root folder)")