1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-23 08:13:14 +00:00

Fixed backups ordering and rotation

This commit is contained in:
morpheus65535 2022-03-14 07:39:38 -04:00
parent 040ddb2362
commit eb63f05768
2 changed files with 5 additions and 1 deletions

View file

@ -33,6 +33,7 @@ def get_restore_path():
def get_backup_files(fullpath=True): def get_backup_files(fullpath=True):
backup_file_pattern = os.path.join(get_backup_path(), 'bazarr_backup_v*.zip') backup_file_pattern = os.path.join(get_backup_path(), 'bazarr_backup_v*.zip')
file_list = glob(backup_file_pattern) file_list = glob(backup_file_pattern)
file_list.sort(key=os.path.getmtime)
if fullpath: if fullpath:
return file_list return file_list
else: else:
@ -179,7 +180,7 @@ def backup_rotation():
logging.debug(f'Cleaning up backup files older than {backup_retention} days') logging.debug(f'Cleaning up backup files older than {backup_retention} days')
for file in backup_files: 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}') logging.debug(f'Deleting old backup file {file}')
try: try:
os.remove(file) os.remove(file)

View file

@ -524,6 +524,9 @@ def check_health():
check_radarr_rootfolder() check_radarr_rootfolder()
event_stream(type='badges') event_stream(type='badges')
from backup import backup_rotation
backup_rotation()
def get_health_issues(): def get_health_issues():
# this function must return a list of dictionaries consisting of to keys: object and issue # this function must return a list of dictionaries consisting of to keys: object and issue