diff --git a/app/classes/controllers/management_controller.py b/app/classes/controllers/management_controller.py index 8f46adc2..4e1f189f 100644 --- a/app/classes/controllers/management_controller.py +++ b/app/classes/controllers/management_controller.py @@ -145,7 +145,8 @@ class ManagementController: excluded_dirs: list = None, compress: bool = False, shutdown: bool = False, - command: str = "", + before: str = "", + after: str = "", ): return self.management_helper.set_backup_config( server_id, @@ -154,7 +155,8 @@ class ManagementController: excluded_dirs, compress, shutdown, - command, + before, + after, ) @staticmethod diff --git a/app/classes/models/management.py b/app/classes/models/management.py index 10529898..221c87b1 100644 --- a/app/classes/models/management.py +++ b/app/classes/models/management.py @@ -131,7 +131,8 @@ class Backups(BaseModel): server_id = ForeignKeyField(Servers, backref="backups_server") compress = BooleanField(default=False) shutdown = BooleanField(default=False) - command = CharField(default="") + before = CharField(default="") + after = CharField(default="") class Meta: table_name = "backups" @@ -370,7 +371,8 @@ class HelpersManagement: "server_id": row.server_id_id, "compress": row.compress, "shutdown": row.shutdown, - "command": row.command, + "before": row.before, + "after": row.after, } except IndexError: conf = { @@ -380,7 +382,8 @@ class HelpersManagement: "server_id": server_id, "compress": False, "shutdown": False, - "command": "", + "before": "", + "after": "", } return conf @@ -396,7 +399,8 @@ class HelpersManagement: excluded_dirs: list = None, compress: bool = False, shutdown: bool = False, - command: str = "", + before: str = "", + after: str = "", ): logger.debug(f"Updating server {server_id} backup config with {locals()}") if Backups.select().where(Backups.server_id == server_id).exists(): @@ -409,7 +413,8 @@ class HelpersManagement: "server_id": server_id, "compress": False, "shutdown": False, - "command": "", + "before": "", + "after": "", } new_row = True if max_backups is not None: @@ -419,7 +424,8 @@ class HelpersManagement: conf["excluded_dirs"] = dirs_to_exclude conf["compress"] = compress conf["shutdown"] = shutdown - conf["command"] = command + conf["before"] = before + conf["after"] = after if not new_row: with self.database.atomic(): if backup_path is not None: diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 43bdc72d..6d0b1e7f 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -1024,12 +1024,12 @@ class ServerInstance: ) time.sleep(3) conf = HelpersManagement.get_backup_config(self.server_id) - if conf["command"]: + if conf["before"]: if self.check_running(): logger.debug( "Found running server and send command option. Sending command" ) - self.send_command(conf["command"]) + self.send_command(conf["before"]) # pause to let people read message. time.sleep(5) if conf["shutdown"]: @@ -1113,6 +1113,14 @@ class ServerInstance: self.run_threaded_server(HelperUsers.get_user_id_by_name("system")) time.sleep(3) self.last_backup_failed = False + if conf["after"]: + if self.check_running(): + logger.debug( + "Found running server and send command option. Sending command" + ) + self.send_command(conf["after"]) + # pause to let people read message. + time.sleep(5) except: logger.exception( f"Failed to create backup of server {self.name} (ID {self.server_id})" diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 8a439a86..0886c38e 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1678,7 +1678,8 @@ class PanelHandler(BaseHandler): compress = self.get_argument("compress", False) shutdown = self.get_argument("shutdown", False) check_changed = self.get_argument("changed") - command = self.get_argument("backup_command", "") + before = self.get_argument("backup_before", "") + after = self.get_argument("backup_after", "") if str(check_changed) == str(1): checked = self.get_body_arguments("root_path") else: @@ -1702,7 +1703,8 @@ class PanelHandler(BaseHandler): excluded_dirs=checked, compress=bool(compress), shutdown=bool(shutdown), - command=command, + before=before, + after=after, ) self.controller.management.add_to_audit_log( diff --git a/app/frontend/templates/panel/server_backup.html b/app/frontend/templates/panel/server_backup.html index d509d359..4af0ba1a 100644 --- a/app/frontend/templates/panel/server_backup.html +++ b/app/frontend/templates/panel/server_backup.html @@ -109,18 +109,35 @@