mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Repaired backup zipper and old backup removals
*Fixed zip arg, should be in quotes *Set while statement to constantly check for and remove old backups *Repaired old backup removal not pulling correct path
This commit is contained in:
parent
5c85a575ee
commit
4757ac0573
@ -324,15 +324,15 @@ class Server:
|
||||
logger.info("Starting server {} (ID {}) backup".format(self.name, self.server_id))
|
||||
conf = db_helper.get_backup_config(self.server_id)
|
||||
try:
|
||||
backup_filename = "{}/{}.zip".format(conf['backup_path'], datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
|
||||
backup_filename = "{}/{}".format(conf['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))
|
||||
# helper.zip_directory(backup_filename, self.server_path)
|
||||
shutil.make_archive(backup_filename, zip, self.server_path)
|
||||
backup_list = self.list_backups()
|
||||
if len(self.list_backups()) > conf["max_backups"]:
|
||||
shutil.make_archive(backup_filename, 'zip', self.server_path)
|
||||
while len(self.list_backups()) > conf["max_backups"]:
|
||||
backup_list = self.list_backups()
|
||||
oldfile = backup_list[0]
|
||||
logger.info("Removing old backup '{}'".format(oldfile))
|
||||
os.remove(oldfile)
|
||||
oldfile_path = "{}/{}".format(conf['backup_path'], oldfile['path'])
|
||||
logger.info("Removing old backup '{}'".format(oldfile['path']))
|
||||
os.remove(oldfile_path)
|
||||
except:
|
||||
logger.exception("Failed to create backup of server {} (ID {})".format(self.name, self.server_id))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user