# `Arcadic.Backup`
[🔗](https://github.com/baselabs/arcadic/blob/baselabs_arcadic-v4.0.1/lib/arcadic/backup.ex#L5)

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.

# `backup`

```elixir
@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!`

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

# `list`

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

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

# `list!`

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

# `restore`

```elixir
@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!`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
