Skip to content

Commit 1507fde

Browse files
committed
pending work reset me
1 parent cf5ce0c commit 1507fde

File tree

4 files changed

+121
-1
lines changed

4 files changed

+121
-1
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default defineConfig({
6161
{ text: 'Installation', link: '/getting-started/installation' },
6262
{ text: 'Basics', link: '/getting-started/basics' },
6363
{ text: 'Supported databases', link: '/getting-started/database-vendors' },
64+
{ text: 'Console tool', link: '/console' },
6465
]
6566
},
6667
{

docs/content/configuration/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ anonymizer:
117117
118118
```ini [Environment]
119119
# Only supports single connection.
120-
DBTOOLS_ANONYMIZER="./db_tools.anonymization.yaml"
120+
DBTOOLS_ANONYMIZER_YAML="./db_tools.anonymization.yaml"
121121
```
122122
:::
123123

docs/content/console.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Console tool, the CLI
2+
3+
DbTools ships a standalone console tool for running it as an application.
4+
5+
If installed via composer, simply run:
6+
7+
```sh
8+
./vendor/bin/db-tools
9+
```
10+
11+
This CLI tool runs outside of the framework and application context, therefore requires
12+
that you provide a dedicated configuration file for it.
13+
14+
:::info
15+
A script that generates a working PHAR file is provided in the repository and can be
16+
used to create a self-contained PHAR archive for running in a docker container, on
17+
a baremetal with PHP installed, etc...
18+
19+
Future plans are to provide an official PHAR archive for each stable release.
20+
:::
21+
22+
## Configuration
23+
24+
### Configuration file
25+
26+
The configuration file is a `YAML` file whose available options are strictly identical
27+
to the Symfony bundle configuration with a few additional parameters dedicated to the
28+
standalone application.
29+
30+
:::tip
31+
Please refer to the [configuration reference](configuration/reference) for a complete
32+
and detailled configuration options list.
33+
:::
34+
35+
The most important and required one is the list of available database connections,
36+
using the `connections` configuration option.
37+
38+
```yaml [Standalone]
39+
connections:
40+
connection_one: "pgsql://username:password@hostname:port?version=16.0&other_option=..."
41+
connection_two: "mysql://username:password@hostname:port?version=8.1&other_option=..."
42+
```
43+
44+
Keys are connection names for idenfying those as a command line option, values are
45+
database URL containing all necessary information and options for connecting.
46+
47+
### Environment variables
48+
49+
@todo
50+
51+
### Anonymizer mapping
52+
53+
Anonymizer tables and columns cannot be configured via command line options since
54+
they necessitate a more complex configuration representation. In order to use the
55+
standalone CLI for anonymizing, you are required to create a mapping configuration
56+
file.
57+
58+
File structure is the same as the documented YAML anonymization configuration file
59+
which can be used as-is.
60+
61+
In order to pass configuration, use the `--anonymizer-config=` option or
62+
`DB_TOOLS_ANONYMIZER_CONFIG=` environment variable, followed by a file relative
63+
or absolute path.
64+
65+
For example:
66+
67+
::: code-group
68+
```sh [Option]
69+
./vendor/bin/db-tools --anonymizer-config=my_config.yaml
70+
```
71+
72+
```sh [Env]
73+
DB_TOOLS_ANONYMIZER_CONFIG=my_config.yaml ./vendor/bin/db-tools
74+
```
75+
:::
76+
77+
### Dumping from Symfony configuration
78+
79+
:::warning
80+
When using the CLI tool, you are not in the Symfony application context anymore,
81+
which means the CLI tool doesn't know the Symfony database configuration, doctrine
82+
connections or doctrine ORM mapping.
83+
:::
84+
85+
@todo
86+
87+
## Backup database
88+
89+
90+
91+
## Restore database
92+
93+
94+
## Anonymize

src/Bridge/Symfony/Resources/config/services.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
parameters:
2+
# Common.
3+
env(DBTOOLS_ANONYMIZER_PATH): ~
4+
env(DBTOOLS_ANONYMIZER): ~
5+
env(DBTOOLS_BACKUP_BINARY_MARIADB): "/usr/bin/mariadb-dump"
6+
env(DBTOOLS_BACKUP_BINARY_MYSQL): "/usr/bin/mysqldump"
7+
env(DBTOOLS_BACKUP_BINARY_POSTGRESQL): "/usr/bin/pg_dump"
8+
env(DBTOOLS_BACKUP_BINARY_SQLITE): "/usr/bin/sqlite3"
9+
env(DBTOOLS_BACKUP_EXCLUDED_TABLES): ~
10+
env(DBTOOLS_BACKUP_EXPIRATION_AGE): ~
11+
env(DBTOOLS_BACKUP_OPTIONS): ~
12+
env(DBTOOLS_BACKUP_TIMEOUT): ~
13+
env(DBTOOLS_RESTORE_BINARY_MARIADB): "/usr/bin/mariadb"
14+
env(DBTOOLS_RESTORE_BINARY_MYSQL): "/usr/bin/mysql"
15+
env(DBTOOLS_RESTORE_BINARY_POSTGRESQL): "/usr/bin/pg_restore"
16+
env(DBTOOLS_RESTORE_BINARY_SQLITE): "/usr/bin/sqlite3"
17+
env(DBTOOLS_RESTORE_OPTIONS): ~
18+
env(DBTOOLS_RESTORE_TIMEOUT): ~
19+
env(DBTOOLS_STORAGE_FILENAME_STRATEGY): ~
20+
env(DBTOOLS_STORAGE_ROOT_DIR): ~
21+
# Standalone only
22+
env(DBTOOLS_CONNECTION): ~
23+
env(DBTOOLS_DEFAULT_CONNECTION): ~
24+
env(DBTOOLS_WORKDIR): ~
25+
126
services:
227
# Commands
328
db_tools.command.anonymization.run:

0 commit comments

Comments
 (0)