Fix backup config bug

This commit is contained in:
Andrew 2022-01-29 16:37:00 -05:00
parent 8232a630ee
commit 37ccc447c4
3 changed files with 10 additions and 2 deletions

View File

@ -1,3 +1,4 @@
from http import server
import sys import sys
import logging import logging
import datetime import datetime
@ -291,10 +292,10 @@ class helpers_management:
@staticmethod @staticmethod
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None): def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None):
logger.debug(f"Updating server {server_id} backup config with {locals()}") logger.debug(f"Updating server {server_id} backup config with {locals()}")
try: if Backups.select().where(Backups.server_id == server_id).count() != 0:
new_row = False new_row = False
conf = {} conf = {}
except IndexError: else:
conf = { conf = {
"directories": None, "directories": None,
"max_backups": 0, "max_backups": 0,

View File

@ -17,6 +17,7 @@ from app.classes.models.management import management_helper
from app.classes.controllers.users_controller import Users_Controller from app.classes.controllers.users_controller import Users_Controller
from app.classes.controllers.servers_controller import Servers_Controller from app.classes.controllers.servers_controller import Servers_Controller
from app.classes.models.servers import servers_helper from app.classes.models.servers import servers_helper
from app.classes.models.users import users_helper
logger = logging.getLogger('apscheduler') logger = logging.getLogger('apscheduler')
@ -373,6 +374,8 @@ class TasksManager:
if not event.exception: if not event.exception:
if str(event.job_id).isnumeric(): if str(event.job_id).isnumeric():
task = management_helper.get_scheduled_task_model(int(event.job_id)) task = management_helper.get_scheduled_task_model(int(event.job_id))
management_helper.add_to_audit_log_raw('system', users_helper.get_user_id_by_name('system'), task.server_id,
f"Task with id {task.schedule_id} completed successfully", '127.0.0.1')
if task.one_time: if task.one_time:
self.remove_job(task.schedule_id) self.remove_job(task.schedule_id)
logger.info("one time task detected. Deleting...") logger.info("one time task detected. Deleting...")

View File

@ -452,6 +452,10 @@ class PanelHandler(BaseHandler):
return return
server = self.controller.get_server_obj(server_id) server = self.controller.get_server_obj(server_id)
management_helper.add_to_audit_log_raw(
self.controller.users.get_user_by_id(exec_user['user_id'])['username'], exec_user['user_id'], server_id,
f"Backup now executed for server {server_id} ",
source_ip=self.get_remote_ip())
server.backup_server() server.backup_server()
self.redirect(f"/panel/server_detail?id={server_id}&subpage=backup") self.redirect(f"/panel/server_detail?id={server_id}&subpage=backup")