summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2022-03-14 07:39:38 -0400
committermorpheus65535 <[email protected]>2022-03-14 07:39:38 -0400
commiteb63f057684e7c2842ba9dd5a9a658e3e9f8edaf (patch)
treed8d8755dbc997c464c80101e6959faf868d9e5f2
parent040ddb236269c7a27d5d4f9c7fe708e53caba72f (diff)
downloadbazarr-eb63f057684e7c2842ba9dd5a9a658e3e9f8edaf.tar.gz
bazarr-eb63f057684e7c2842ba9dd5a9a658e3e9f8edaf.zip
Fixed backups ordering and rotation
-rw-r--r--bazarr/backup.py3
-rw-r--r--bazarr/utils.py3
2 files changed, 5 insertions, 1 deletions
diff --git a/bazarr/backup.py b/bazarr/backup.py
index 81ccf68ab..53760ac62 100644
--- a/bazarr/backup.py
+++ b/bazarr/backup.py
@@ -33,6 +33,7 @@ def get_restore_path():
def get_backup_files(fullpath=True):
backup_file_pattern = os.path.join(get_backup_path(), 'bazarr_backup_v*.zip')
file_list = glob(backup_file_pattern)
+ file_list.sort(key=os.path.getmtime)
if fullpath:
return file_list
else:
@@ -179,7 +180,7 @@ def backup_rotation():
logging.debug(f'Cleaning up backup files older than {backup_retention} days')
for file in backup_files:
- if datetime.fromtimestamp(os.path.getmtime(file)) + timedelta(days=backup_retention) < datetime.utcnow():
+ if datetime.fromtimestamp(os.path.getmtime(file)) + timedelta(days=int(backup_retention)) < datetime.utcnow():
logging.debug(f'Deleting old backup file {file}')
try:
os.remove(file)
diff --git a/bazarr/utils.py b/bazarr/utils.py
index b9eb2b2e5..def8439e4 100644
--- a/bazarr/utils.py
+++ b/bazarr/utils.py
@@ -524,6 +524,9 @@ def check_health():
check_radarr_rootfolder()
event_stream(type='badges')
+ from backup import backup_rotation
+ backup_rotation()
+
def get_health_issues():
# this function must return a list of dictionaries consisting of to keys: object and issue