From 24e0e3be6df9dba2e7f18716ac0ee59093b5d06b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 25 Apr 2023 23:33:32 +0200 Subject: [PATCH] Added additional information about how much disc space gets freed --- .../server_native-backups-cleanup/files/backups-cleanup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/roles/server_native-backups-cleanup/files/backups-cleanup.py b/roles/server_native-backups-cleanup/files/backups-cleanup.py index 02374e9e..3a0eb337 100644 --- a/roles/server_native-backups-cleanup/files/backups-cleanup.py +++ b/roles/server_native-backups-cleanup/files/backups-cleanup.py @@ -46,9 +46,13 @@ for host_backup_directory_name in os.listdir(args.backups_folder_path): print("Directory %s is used by another process. Skipped." % (version_path)) continue - if psutil.disk_usage(args.backups_folder_path).percent > args.maximum_backup_size_percent: + old_disc_usage_percent=psutil.disk_usage(args.backups_folder_path).percent + if old_disc_usage_percent > args.maximum_backup_size_percent: print("Deleting %s to free space." % (version_path)) shutil.rmtree(version_path) + new_disc_usage_percent=psutil.disk_usage(args.backups_folder_path).percent + difference_percent=old_disc_usage_percent-new_disc_usage_percent + print("{:6.2f} %% of drive freed".format(difference_percent)) continue if os.path.exists(version_status_pulling_path):