prune database backups even if there's more than 5

This commit is contained in:
jesopo 2019-10-14 18:07:18 +01:00
parent 920456ea17
commit fe16c0132f

View file

@ -18,8 +18,9 @@ class Module(ModuleManager.BaseModule):
files = glob.glob("%s.*" % location) files = glob.glob("%s.*" % location)
files = sorted(files) files = sorted(files)
if len(files) == 5: while len(files) > 4:
os.remove(files[0]) os.remove(files[-1])
files.pop(-1)
suffix = datetime.datetime.now().strftime("%y-%m-%d.%H:%M:%S") suffix = datetime.datetime.now().strftime("%y-%m-%d.%H:%M:%S")
backup_file = "%s.%s" % (location, suffix) backup_file = "%s.%s" % (location, suffix)