> ## Documentation Index
> Fetch the complete documentation index at: https://libops-renovate-github-com-libops-sitectl-isle-0-x.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MariaDB service commands

> Core sitectl MariaDB operations for backups, restores, sync, and service inspection.

export const Compose = () => <Tooltip headline="Compose" tip={<>
        Docker Compose is Docker's tool for defining and running multi-container applications.{" "}
        <a href="https://docs.docker.com/compose/">https://docs.docker.com/compose/</a>.
      </>}>
    <>
      <Icon icon="docker" />
      {" "}
      Compose
    </>
  </Tooltip>;

MariaDB is a core `sitectl` service namespace. Operators use `sitectl mariadb ...` from any context whose <Compose /> project has a MariaDB-compatible service.

## Backups

Export a SQL backup from the active context:

```bash theme={null}
sitectl mariadb backup --output /tmp/site.sql.gz --gzip
sitectl mariadb backup appdb --output /tmp/appdb.sql.gz --gzip
```

Without a database argument, `backup` exports all databases. The command runs `mariadb-dump` or `mysqldump` inside the database service and reads the root password from `/run/secrets/DB_ROOT_PASSWORD`, `MARIADB_ROOT_PASSWORD`, or `MYSQL_ROOT_PASSWORD`.

Use `--service` when a project uses a different database service name.

## Restore

Import a SQL backup into the active context:

```bash theme={null}
sitectl mariadb restore /tmp/site.sql.gz --yolo
sitectl mariadb restore /tmp/appdb.sql.gz appdb
```

Restore is destructive. Without `--yolo`, sitectl prompts before replacing the target database.

## Sync

Sync a database artifact between two sitectl contexts:

```bash theme={null}
sitectl mariadb sync --source production --target staging --database appdb
```

The sync flow reuses a recent source backup when possible, stages the artifact between contexts, and runs the same confirmed restore path on the target.

## Inspection

Check the MariaDB container status:

```bash theme={null}
sitectl mariadb status
```

Standalone MariaDB Compose projects may still exist, but the shared command surface belongs to core `sitectl`, not to a dedicated MariaDB CLI plugin.

## Reference

### `backup`

Export a MariaDB SQL backup from the active compose stack

```bash theme={null}
sitectl mariadb backup [DATABASE]
```

| Flag              | Default   | Description                                       |
| ----------------- | --------- | ------------------------------------------------- |
| `--all-databases` | `false`   | Export all databases explicitly                   |
| `--gzip`          | `false`   | Compress the backup with gzip                     |
| `-o, --output`    |           | Write SQL backup to a host path instead of stdout |
| `--service`       | `mariadb` | MariaDB compose service name                      |

### `restore`

Import a MariaDB SQL backup into the active compose stack

```bash theme={null}
sitectl mariadb restore INPUT [DATABASE]
```

| Flag         | Default   | Description                                             |
| ------------ | --------- | ------------------------------------------------------- |
| `--database` |           | Database to replace before import                       |
| `--service`  | `mariadb` | MariaDB compose service name                            |
| `--yolo`     | `false`   | Apply destructive database changes without confirmation |

### `sync`

Sync a MariaDB database artifact between contexts

```bash theme={null}
sitectl mariadb sync
```

| Flag           | Default                               | Description                                                  |
| -------------- | ------------------------------------- | ------------------------------------------------------------ |
| `--backup-dir` | `/tmp/sitectl-mariadb-jobs/db-backup` | Directory on the source host used to cache backup artifacts  |
| `--database`   |                                       | Database to sync instead of all databases                    |
| `--fresh`      | `false`                               | Always take a fresh backup instead of reusing one from today |
| `--service`    | `mariadb`                             | MariaDB compose service name                                 |
| `--source`     |                                       | Source sitectl context                                       |
| `--target`     |                                       | Target sitectl context                                       |
| `--yolo`       | `false`                               | Skip the confirmation prompt before importing                |

### `status`

Show the compose service container status

```bash theme={null}
sitectl mariadb status
```

| Flag        | Default   | Description          |
| ----------- | --------- | -------------------- |
| `--service` | `mariadb` | Compose service name |
