Arcadic.Backup (Arcadic v0.7.0)

Copy Markdown View Source

Backup and restore over ArcadeDB. backup/2 runs BACKUP DATABASE on conn.database (optional :to '<url>' single-quoted target); list/1 runs list backups <db>; restore/3 runs restore database <name> <url>. Tenant-blind.

URLs are interpolated (server commands / the BACKUP SQL literal cannot bind params), so a target URL and the restore <name>/<url> are allowlist-validated value-free BEFORE any wire call: name via Arcadic.Identifier, url via Arcadic.Identifier.validate_url/1 (RFC-3986 positive allowlist + http/https/file scheme). The allowlist excludes the single quote ' (so a :to URL cannot break out of BACKUP DATABASE '<url>') and ALL whitespace + control characters. The restore <url> is interpolated bare (a rest-of-line literal server-side): a second server command needs whitespace to form its tokens (drop database <name> has spaces), so excluding whitespace makes a second statement unconstructible regardless of how the server treats an in-token ;/#. SSRF note: whether the server blocks private/loopback restore sources is server-config-dependent — treat the URL as trusted operator input.

Summary

Functions

Back up conn.database. :to '<url>' overrides the server's default backup directory.

List backups for conn.database (list backups <db>).

Restore a database name from a backup url (restore database <name> <url>). Validates both.

Functions

backup(conn, opts \\ [])

@spec backup(
  Arcadic.Conn.t(),
  keyword()
) :: {:ok, map()} | {:error, atom() | Exception.t()}

Back up conn.database. :to '<url>' overrides the server's default backup directory.

backup!(conn, opts \\ [])

@spec backup!(
  Arcadic.Conn.t(),
  keyword()
) :: map()

list(conn)

@spec list(Arcadic.Conn.t()) :: {:ok, map()} | {:error, Exception.t()}

List backups for conn.database (list backups <db>).

list!(conn)

@spec list!(Arcadic.Conn.t()) :: map()

restore(conn, name, url)

@spec restore(Arcadic.Conn.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, atom() | Exception.t()}

Restore a database name from a backup url (restore database <name> <url>). Validates both.

restore!(conn, name, url)

@spec restore!(Arcadic.Conn.t(), String.t(), String.t()) :: map()