Oops! All backups are gone... but not anymore!

While loop automatically removed all old backups greater than the max backups threshold... including if it was set to 0. Set a test for the while loop to make sure max backups is greater than 0 before deletey delete
This commit is contained in:
Scott R 2021-08-14 00:07:24 -05:00
parent 5b8764cb45
commit 689e4abb51

View File

@ -369,7 +369,7 @@ class Server:
backup_filename = "{}/{}".format(self.settings['backup_path'], datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
logger.info("Creating backup of server '{}' (ID#{}) at '{}'".format(self.settings['server_name'], self.server_id, backup_filename))
shutil.make_archive(backup_filename, 'zip', self.server_path)
while len(self.list_backups()) > conf["max_backups"]:
while len(self.list_backups()) > conf["max_backups"] and conf["max_backups"] > 0:
backup_list = self.list_backups()
oldfile = backup_list[0]
oldfile_path = "{}/{}".format(conf['backup_path'], oldfile['path'])