Skip to content

Commit

Permalink
[core][fix] Backup: correct endpoint when using https (#2123)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Jun 24, 2024
1 parent 1b557e6 commit 09c24b2
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions fixcore/fixcore/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3724,7 +3724,12 @@ async def create_backup(self, arg: Optional[str]) -> AsyncIterator[JsonElement]:
try:
db_config = self.dependencies.config.db
if not shutil.which("arangodump"):
raise CLIParseError("db_backup expects the executable `arangodump` to be in path!")
raise CLIParseError("backup expects the executable `arangodump` to be in path!")
if db_config.server.startswith("https"):
endpoint = db_config.server.replace("https", "http+ssl")
else:
endpoint = db_config.server.replace("http", "http+tcp")

# fmt: off
process = await asyncio.create_subprocess_exec(
"arangodump",
Expand All @@ -3734,8 +3739,8 @@ async def create_backup(self, arg: Optional[str]) -> AsyncIterator[JsonElement]:
"--log.level", "error", # only print error messages
"--output-directory", temp_dir, # directory to write to
"--overwrite", "true", # required for existing directories
"--server.endpoint", db_config.server.replace("http", "http+tcp"),
"--server.authentication", "false" if db_config.no_ssl_verify else "true",
"--server.endpoint", endpoint,
"--server.authentication", "false",
"--server.database", db_config.database,
"--server.username", db_config.username,
"--server.password", db_config.password,
Expand Down Expand Up @@ -3785,7 +3790,14 @@ async def restore_backup(self, backup_file: Optional[str], ctx: CLIContext) -> A
tar.extractall(temp_dir, members=safe_members_in_tarfile(tar))

# fmt: off
db_conf = self.dependencies.config.db
db_config = self.dependencies.config.db
if not shutil.which("arangorestore"):
raise CLIParseError("restore expects the executable `arangorestore` to be in path!")
if db_config.server.startswith("https"):
endpoint = db_config.server.replace("https", "http+ssl")
else:
endpoint = db_config.server.replace("http", "http+tcp")

process = await asyncio.create_subprocess_exec(
"arangorestore",
"--progress", "false", # do not show progress
Expand All @@ -3794,11 +3806,11 @@ async def restore_backup(self, backup_file: Optional[str], ctx: CLIContext) -> A
"--log.level", "error", # only print error messages
"--input-directory", temp_dir, # directory to write to
"--overwrite", "true", # required for existing db collections
"--server.endpoint", db_conf.server.replace("http", "http+tcp"),
"--server.authentication", "false" if db_conf.no_ssl_verify else "true",
"--server.database", db_conf.database,
"--server.username", db_conf.username,
"--server.password", db_conf.password,
"--server.endpoint", endpoint,
"--server.authentication", "false",
"--server.database", db_config.database,
"--server.username", db_config.username,
"--server.password", db_config.password,
"--configuration", "none",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
Expand Down

0 comments on commit 09c24b2

Please sign in to comment.