Merge branch 'refactor/backups' into refactor/upload-api

This commit is contained in:
amcmanu3 2024-06-25 13:48:35 -04:00
commit d6e00edf4a
2 changed files with 8 additions and 0 deletions

View File

@ -397,6 +397,9 @@ class HelpersManagement:
Backups.delete().where(Backups.backup_id == backup_id).execute()
def add_backup_config(self, conf) -> str:
if "excluded_dirs" in conf:
dirs_to_exclude = ",".join(conf["excluded_dirs"])
conf["excluded_dirs"] = dirs_to_exclude
backup = Backups.create(**conf)
logger.debug("Creating new backup record.")
return backup.backup_id

View File

@ -1,3 +1,4 @@
import os
import logging
import json
from jsonschema import validate
@ -97,6 +98,10 @@ class ApiServersServerBackupsIndexHandler(BaseApiHandler):
if EnumPermissionsServer.BACKUP not in server_permissions:
# if the user doesn't have Schedule permission, return an error
return self.finish_json(400, {"status": "error", "error": "NOT_AUTHORIZED"})
# Set the backup location automatically for non-super users. We should probably
# make the default location configurable for SU eventually
if not auth_data[4]["superuser"]:
data["backup_location"] = os.path.join(self.helper.backup_path, server_id)
data["server_id"] = server_id
if not data.get("excluded_dirs", None):
data["excluded_dirs"] = []