Skip to content

Commit

Permalink
pending work reset me
Browse files Browse the repository at this point in the history
  • Loading branch information
pounard committed May 28, 2024
1 parent cf5ce0c commit 1507fde
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default defineConfig({
{ text: 'Installation', link: '/getting-started/installation' },
{ text: 'Basics', link: '/getting-started/basics' },
{ text: 'Supported databases', link: '/getting-started/database-vendors' },
{ text: 'Console tool', link: '/console' },
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/content/configuration/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ anonymizer:
```ini [Environment]
# Only supports single connection.
DBTOOLS_ANONYMIZER="./db_tools.anonymization.yaml"
DBTOOLS_ANONYMIZER_YAML="./db_tools.anonymization.yaml"
```
:::

Expand Down
94 changes: 94 additions & 0 deletions docs/content/console.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Console tool, the CLI

DbTools ships a standalone console tool for running it as an application.

If installed via composer, simply run:

```sh
./vendor/bin/db-tools
```

This CLI tool runs outside of the framework and application context, therefore requires
that you provide a dedicated configuration file for it.

:::info
A script that generates a working PHAR file is provided in the repository and can be
used to create a self-contained PHAR archive for running in a docker container, on
a baremetal with PHP installed, etc...

Future plans are to provide an official PHAR archive for each stable release.
:::

## Configuration

### Configuration file

The configuration file is a `YAML` file whose available options are strictly identical
to the Symfony bundle configuration with a few additional parameters dedicated to the
standalone application.

:::tip
Please refer to the [configuration reference](configuration/reference) for a complete
and detailled configuration options list.
:::

The most important and required one is the list of available database connections,
using the `connections` configuration option.

```yaml [Standalone]
connections:
connection_one: "pgsql://username:password@hostname:port?version=16.0&other_option=..."
connection_two: "mysql://username:password@hostname:port?version=8.1&other_option=..."
```
Keys are connection names for idenfying those as a command line option, values are
database URL containing all necessary information and options for connecting.
### Environment variables
@todo
### Anonymizer mapping
Anonymizer tables and columns cannot be configured via command line options since
they necessitate a more complex configuration representation. In order to use the
standalone CLI for anonymizing, you are required to create a mapping configuration
file.
File structure is the same as the documented YAML anonymization configuration file
which can be used as-is.
In order to pass configuration, use the `--anonymizer-config=` option or
`DB_TOOLS_ANONYMIZER_CONFIG=` environment variable, followed by a file relative
or absolute path.

For example:

::: code-group
```sh [Option]
./vendor/bin/db-tools --anonymizer-config=my_config.yaml
```

```sh [Env]
DB_TOOLS_ANONYMIZER_CONFIG=my_config.yaml ./vendor/bin/db-tools
```
:::

### Dumping from Symfony configuration

:::warning
When using the CLI tool, you are not in the Symfony application context anymore,
which means the CLI tool doesn't know the Symfony database configuration, doctrine
connections or doctrine ORM mapping.
:::

@todo

## Backup database



## Restore database


## Anonymize
25 changes: 25 additions & 0 deletions src/Bridge/Symfony/Resources/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
parameters:
# Common.
env(DBTOOLS_ANONYMIZER_PATH): ~
env(DBTOOLS_ANONYMIZER): ~
env(DBTOOLS_BACKUP_BINARY_MARIADB): "/usr/bin/mariadb-dump"
env(DBTOOLS_BACKUP_BINARY_MYSQL): "/usr/bin/mysqldump"
env(DBTOOLS_BACKUP_BINARY_POSTGRESQL): "/usr/bin/pg_dump"
env(DBTOOLS_BACKUP_BINARY_SQLITE): "/usr/bin/sqlite3"
env(DBTOOLS_BACKUP_EXCLUDED_TABLES): ~
env(DBTOOLS_BACKUP_EXPIRATION_AGE): ~
env(DBTOOLS_BACKUP_OPTIONS): ~
env(DBTOOLS_BACKUP_TIMEOUT): ~
env(DBTOOLS_RESTORE_BINARY_MARIADB): "/usr/bin/mariadb"
env(DBTOOLS_RESTORE_BINARY_MYSQL): "/usr/bin/mysql"
env(DBTOOLS_RESTORE_BINARY_POSTGRESQL): "/usr/bin/pg_restore"
env(DBTOOLS_RESTORE_BINARY_SQLITE): "/usr/bin/sqlite3"
env(DBTOOLS_RESTORE_OPTIONS): ~
env(DBTOOLS_RESTORE_TIMEOUT): ~
env(DBTOOLS_STORAGE_FILENAME_STRATEGY): ~
env(DBTOOLS_STORAGE_ROOT_DIR): ~
# Standalone only
env(DBTOOLS_CONNECTION): ~
env(DBTOOLS_DEFAULT_CONNECTION): ~
env(DBTOOLS_WORKDIR): ~

services:
# Commands
db_tools.command.anonymization.run:
Expand Down

0 comments on commit 1507fde

Please sign in to comment.