mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 17:55:29 +01:00
Merge branch 'bugfix/schedule-restore' into 'dev'
Fix Schedule Restore | Add Backup Config Preservation See merge request crafty-controller/crafty-4!533
This commit is contained in:
commit
e9b34b81a8
@ -4,6 +4,7 @@
|
||||
TBD
|
||||
### Bug fixes
|
||||
- Fix local java server imports. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/529))
|
||||
- Fix Schedule Restore | Add Backup Config Preservation. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/533))
|
||||
### Tweaks
|
||||
- Added further login screen customisation settings. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/531))
|
||||
### Lang
|
||||
|
@ -97,6 +97,10 @@ class ManagementController:
|
||||
command,
|
||||
name,
|
||||
enabled=True,
|
||||
one_time=False,
|
||||
cron_string="* * * * *",
|
||||
parent=None,
|
||||
delay=0,
|
||||
):
|
||||
return HelpersManagement.create_scheduled_task(
|
||||
server_id,
|
||||
@ -107,6 +111,10 @@ class ManagementController:
|
||||
command,
|
||||
name,
|
||||
enabled,
|
||||
one_time,
|
||||
cron_string,
|
||||
parent,
|
||||
delay,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
@ -442,15 +442,8 @@ class AjaxHandler(BaseHandler):
|
||||
for schedule in self.controller.management.get_schedules_by_server(
|
||||
server_id
|
||||
):
|
||||
self.controller.management.create_scheduled_task(
|
||||
new_server_id,
|
||||
schedule.action,
|
||||
schedule.interval,
|
||||
schedule.interval_type,
|
||||
schedule.start_time,
|
||||
schedule.command,
|
||||
schedule.name,
|
||||
schedule.enabled,
|
||||
self.tasks_manager.update_job(
|
||||
schedule.schedule_id, {"server_id": new_server_id}
|
||||
)
|
||||
# preserve execution command
|
||||
new_server_obj = self.controller.servers.get_server_obj(
|
||||
@ -458,6 +451,29 @@ class AjaxHandler(BaseHandler):
|
||||
)
|
||||
new_server_obj.execution_command = server_data["execution_command"]
|
||||
self.controller.servers.update_server(new_server_obj)
|
||||
|
||||
# preserve backup config
|
||||
backup_config = self.controller.management.get_backup_config(
|
||||
server_id
|
||||
)
|
||||
excluded_dirs = []
|
||||
server_obj = self.controller.servers.get_server_obj(server_id)
|
||||
loop_backup_path = self.helper.wtol_path(server_obj.path)
|
||||
for item in self.controller.management.get_excluded_backup_dirs(
|
||||
server_id
|
||||
):
|
||||
item_path = self.helper.wtol_path(item)
|
||||
bu_path = os.path.relpath(item_path, loop_backup_path)
|
||||
bu_path = os.path.join(new_server_obj.path, bu_path)
|
||||
excluded_dirs.append(bu_path)
|
||||
self.controller.management.set_backup_config(
|
||||
new_server_id,
|
||||
new_server_obj.backup_path,
|
||||
backup_config["max_backups"],
|
||||
excluded_dirs,
|
||||
backup_config["compress"],
|
||||
backup_config["shutdown"],
|
||||
)
|
||||
# remove old server's tasks
|
||||
try:
|
||||
self.tasks_manager.remove_all_server_tasks(server_id)
|
||||
@ -486,15 +502,8 @@ class AjaxHandler(BaseHandler):
|
||||
for schedule in self.controller.management.get_schedules_by_server(
|
||||
server_id
|
||||
):
|
||||
self.controller.management.create_scheduled_task(
|
||||
new_server_id,
|
||||
schedule.action,
|
||||
schedule.interval,
|
||||
schedule.interval_type,
|
||||
schedule.start_time,
|
||||
schedule.command,
|
||||
schedule.name,
|
||||
schedule.enabled,
|
||||
self.tasks_manager.update_job(
|
||||
schedule.schedule_id, {"server_id": new_server_id}
|
||||
)
|
||||
# preserve execution command
|
||||
new_server_obj = self.controller.servers.get_server_obj(
|
||||
@ -502,6 +511,29 @@ class AjaxHandler(BaseHandler):
|
||||
)
|
||||
new_server_obj.execution_command = server_data["execution_command"]
|
||||
self.controller.servers.update_server(new_server_obj)
|
||||
|
||||
# preserve backup config
|
||||
backup_config = self.controller.management.get_backup_config(
|
||||
server_id
|
||||
)
|
||||
excluded_dirs = []
|
||||
server_obj = self.controller.servers.get_server_obj(server_id)
|
||||
loop_backup_path = self.helper.wtol_path(server_obj.path)
|
||||
for item in self.controller.management.get_excluded_backup_dirs(
|
||||
server_id
|
||||
):
|
||||
item_path = self.helper.wtol_path(item)
|
||||
bu_path = os.path.relpath(item_path, loop_backup_path)
|
||||
bu_path = os.path.join(new_server_obj.path, bu_path)
|
||||
excluded_dirs.append(bu_path)
|
||||
self.controller.management.set_backup_config(
|
||||
new_server_id,
|
||||
new_server_obj.backup_path,
|
||||
backup_config["max_backups"],
|
||||
excluded_dirs,
|
||||
backup_config["compress"],
|
||||
backup_config["shutdown"],
|
||||
)
|
||||
try:
|
||||
self.tasks_manager.remove_all_server_tasks(server_id)
|
||||
except:
|
||||
|
Loading…
x
Reference in New Issue
Block a user