Skip to content

Commit 028a896

Browse files
committed
no issue - much better configuration
1 parent f31402f commit 028a896

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1244
-705
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22

33
## Next
44

5+
* [feature] ⭐️ The CLI tool can run without configuration using only environment variables (#191).
6+
* [feature] ⭐️ All global options can now be configured on a per-connection basis in `connections.NAME.OPTION` (#191).
57
* [feature] ⭐️ Add `bin/db-tools` CLI command allowing standalone usage (#153).
68
* [experimental] ⭐️ Add `bin/compile` CLI command for building a PHAR file (#154).
9+
* [deprecation] `excluded_tables` is replaced by either `backup_excluded_tables` or `connections.NAME.backup_excluded_tables` (#191).
10+
* [deprecation] `storage.filename_strategy` is replaced by either `storage_filename_strategy` or `connections.NAME.filename_strategy` (#191).
11+
* [deprecation] `storage.root_dir` is replaced by either `storage_directory` or `connections.NAME.storage_directory` (#191).
12+
* [bc] `backupper_binaries` (array) is replaced by either `backup_binary` (string) or `connections.NAME.backup_binary` (string) (#191).
13+
* [bc] `backupper_options` (array) is replaced by either `backup_options` (string) or `connections.NAME.backup_options` (string) (#191).
14+
* [bc] `restorer_binaries` (array) is replaced by either `restore_binary` (string) or `connections.NAME.restore_binary` (string) (#191).
15+
* [bc] `restorer_options` (array) is replaced by either `restore_options` (string) or `connections.NAME.restore_options` (string) (#191).
716
* [bc] Password anonymizer `symfony/password-hasher` dependency is now optional and must be manually installed (#155).
817
* [fix] Property must not be accessed before initialization error when using `--list` option (#183, @iNem0o).
918
* [internal] All Doctrine related dependencies are now optional (#155).

UPGRADE.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Upgrade guide
2+
3+
## Next
4+
5+
### Configuration file structure change
6+
7+
The 2.0 version introduces many configuration changes. Most of them will
8+
gracefuly fallback to older version until 3.0, but some have been removed
9+
and will cause exceptions.
10+
11+
Rationale is that now, all top-level configuration options can be directly
12+
set at the connection level, and we renamed those options to be more consistent
13+
and more explicit about what they do.
14+
15+
Please read carefully the new sample configuration files:
16+
- For Symfony: [config/packages/db_tools.yaml](./config/packages/db_tools.yaml)
17+
- For standalone: [config/db_tools.standalone.yaml](./config/db_tools.standalone.yaml)
18+
19+
And the the [CHANGELOG.md](./CHANGELOG.md) file and fix your configuration accordingly.
20+
21+
The `backupper_binaries` and `backupper_options` as well as the `restorer_binaries`
22+
and `restorer_options` options have been removed and will raise exception when
23+
kept: older version allowed to configure backup and restore binaries on a per-vendor
24+
basis, they are now configured on a per-connection basis without considering the
25+
database vendor anymore. Please set those options for each connection instead.
Lines changed: 102 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,127 @@
11
# This configuration file is an example for standalone usage.
2-
#
3-
# The given parameters you will find in this file must not be set in a Symfony
4-
# application context, and will be ignored if so.
5-
#
6-
# All other configuration you can find in the ./packages/db_tools.yaml file
7-
# can be added in this file, you must simply omit the 'db_tools:' top level
8-
# node.
2+
# Only required parameter is the connection URL.
93

104
# Working directory is the path to which all relative file references will
115
# be relative to. If none set, the path will be this file directory instead.
12-
workdir: /var/www/my_project/
13-
14-
# Database connections.
15-
# One line per connection, a single database URL, all options as query
16-
# parameters. Connections will be made using makincorpus/query-builder
17-
# which will raise exceptions when invalid options are found.
18-
# There is less configuration amplitude than using doctrine/dbal in
19-
# Symfony, yet it should be enough in most case.
20-
# In case any options or specific behaviour is missing, please file
21-
# an issue at https://github.com/makinacorpus/php-query-builder/issues
22-
connections:
23-
connection_one: "pgsql://username:password@hostname:port?version=16.0&other_option=..."
24-
connection_two: "mysql://username:password@hostname:port?version=8.1&other_option=..."
25-
26-
# If you have a single connection, you can use this syntax. In this case
27-
# the connection name will be "default".
28-
# connections: "pgsql://username:password@hostname:port?version=16.0&other_option=..."
6+
# In most cases, you will not need it.
7+
#workdir: .
298

30-
# You can explicitely set which will be default connection in use when
31-
# none providen in the command line options. If you omit this configuration
32-
# value, then the first one in the list will be used.
33-
#default_connection: connection_one
9+
# Where to put generated backups.
10+
# Root directory of the backup storage manager. Default filename
11+
# strategy will always use this folder as root path.
12+
#storage_directory: ./var/db_tools
3413

35-
# Using the DbToolsBundle standalone, you must provide at least
36-
# a root directory for backups.
37-
storage:
38-
# Path can be relative or absolute, Relative paths are relative to the
39-
# workdir option if specified, or from this configuration file directory
40-
# otherwise.
41-
# If none provided, the default will be the following one.
42-
root_dir: ./var/db_tools
43-
# Filename strategies. You may specify one strategy for each doctrine
44-
# connection. Keys are doctrine connection names. Values are strategy
45-
# names, "default" (or null) or omitting the connection will use the
46-
# default implementation.
47-
# If you created and registered a custom one into the container as a
48-
# service, you may simply set the service identifier. If no service
49-
# exists, and your implementation does not require parameters, simply
50-
# set the class name.
51-
#filename_strategy:
52-
# Backup filename strategy.
53-
# "default" is an alias of "datetime"
54-
#default: default
55-
# "datetime" implementation is ROOT_DIR/YYYY/MM/<connection-name>-<datestamp>.<ext>"
56-
#other_connection_strategy: datetime
57-
# Example of using a service name:
58-
#yet_another_connection: app.db_tools.filename.custom_strategy
59-
# Or a classe name:
60-
#another_one: App\DbTools\Storage\MyCustomStrategy
61-
62-
# When old backups are considered obsolete
14+
# Default filename strategy. You may specify one strategy for each doctrine
15+
# connection.
16+
# If you created and registered a custom one into the container as a
17+
# service, you may simply set the service identifier. If no service
18+
# exists, and your implementation does not require parameters, simply
19+
# set the class name.
20+
# Allowed values are:
21+
# - "default": alias of "datetime".
22+
# - "datetime": implementation is "%db_tools.storage_directory%/YYYY/MM/<connection-name>-<datestamp>.<ext>".
23+
# - CLASS_NAME: a class name to use that implements a strategy.
24+
#storage_filename_strategy: default
25+
26+
# When old backups are considered obsolete.
6327
# (Use relative date/time formats : https://www.php.net/manual/en/datetime.formats.relative.php)
6428
#backup_expiration_age: '6 months ago' # default '3 months ago'
6529

66-
# Timeout for backups.
67-
# backup_timeout: 1200 # default 600
68-
69-
# Timeout for restores.
70-
# restore_timeout: 2400 # default 1800
71-
72-
# List here tables (per connection) you don't want in your backups
73-
#excluded_tables:
74-
#default: ['table1', 'table2']
75-
76-
# Specify here paths to binaries, only if the system can't find them by himself
77-
# platform are 'mysql', 'postgresql', 'sqlite'
78-
#backupper_binaries:
79-
#mariadb: '/usr/bin/mariadb-dump' # default 'mariadb-dump'
80-
#mysql: '/usr/bin/mysqldump' # default 'mysqldump'
81-
#postgresql: '/usr/bin/pg_dump' # default 'pg_dump'
82-
#sqlite: '/usr/bin/sqlite3' # default 'sqlite3'
83-
#restorer_binaries:
84-
#mariadb: '/usr/bin/mariadb' # default 'mariadb'
85-
#mysql: '/usr/bin/mysql' # default 'mysql'
86-
#postgresql: '/usr/bin/pg_restore' # default 'pg_restore'
87-
#sqlite: '/usr/bin/sqlite3' # default 'sqlite3'
88-
89-
# Default options to pass to the binary when backing up or restoring
90-
# a database. Those options must be defined per connection.
91-
# If you do not define some default options, here or by using the
92-
# "--extra-options" option when invoking the command, the following
93-
# ones will be used according to the database vendor:
94-
# - When backing up:
95-
# - MariaDB: --no-tablespaces
96-
# - MySQL: --no-tablespaces
97-
# - PostgreSQL: -Z 5 --lock-wait-timeout=120
98-
# - SQLite: -bail
99-
# - When restoring:
100-
# - MariaDB: None
101-
# - MySQL: None
102-
# - PostgreSQL: -j 2 --clean --if-exists --disable-triggers
103-
# - SQLite: None
104-
#backupper_options:
105-
#default: ''
106-
#another_connection: ''
107-
#restorer_options:
108-
#default: ''
109-
#another_connection: ''
30+
# Default timeout for backup process.
31+
#backup_timeout: 1200 # default 600
32+
33+
# Default timeout for restore process.
34+
#restore_timeout: 2400 # default 1800
35+
36+
# List here tables (you don't want in your backups.
37+
# If you have more than one connection, it is strongly advised to configure
38+
# this for each connection instead.
39+
#backup_excluded_tables: ['table1', 'table2']
40+
41+
# Specify here paths to backup and restore binaries and command line options.
42+
# Warning: this will apply to all connections disregarding their database
43+
# vendor. If you have more than one connection and if they use different
44+
# database vendors or versions, please configure those for each connection
45+
# instead.
46+
# Default values depends upon vendor and are documented at
47+
# https://dbtoolsbundle.readthedocs.io/en/stable/configuration.html
48+
#backup_binary: '/usr/bin/pg_dump'
49+
#backup_options: '-Z 5 --lock-wait-timeout=120'
50+
#restore_binary: '/usr/bin/pg_restore'
51+
#restore_options: '-j 2 --clean --if-exists --disable-triggers'
52+
53+
# If you have a single connection, you can use this syntax.
54+
# Connection name will be "default" when configured this way.
55+
connections: "pgsql://username:password@hostname:port?version=16.0&other_option=..."
56+
57+
# Alternatively, you are allowed to have more than one connections, case
58+
# in which you might synthesize the configuration as this:
59+
#connections:
60+
# connection_one: "pgsql://username:password@hostname:port?version=16.0&other_option=..."
61+
# connection_two: "mysql://username:password@hostname:port?version=8.1&other_option=..."
62+
63+
# For advanced usage, you may also override any parameter for each connection.
64+
# Each key is a connection name, all parameters above are allowed for each
65+
# unique connection.
66+
#connections:
67+
# connection_one:
68+
# # Connection URL for connecting.
69+
# # Please refer to makinacorpus/db-query-builder or documentation for more information.
70+
# # Any URL built for doctrine/dbal usage should work.
71+
# # URL is the sole mandatory parameter.
72+
# # Complete list of accepted parameters follows.
73+
# url: "pgsql://username:password@hostname:port?version=16.0&other_option=..."
74+
# backup_binary: /usr/local/bin/vendor-one-dump
75+
# backup_excluded_tables: ['table_one', 'table_two']
76+
# backup_expiration_age: '1 month ago'
77+
# backup_options: --no-table-lock
78+
# backup_timeout: 2000
79+
# restore_binary: /usr/local/bin/vendor-one-restore
80+
# restore_options: --disable-triggers --other-option
81+
# restore_timeout: 5000
82+
# storage_directory: /path/to/storage
83+
# storage_filename_strategy: datetime
84+
# connection_two:
85+
# url: "mysql://username:password@hostname:port?version=8.1&other_option=..."
86+
# # ...
87+
88+
# You can explicitely set which will be default connection in use when
89+
# none providen in the command line options. If you omit this configuration
90+
# value, then the first one in the list will be used.
91+
#default_connection: connection_one
11092

11193
# Update this configuration if you want to look for anonymizers in a custom folder.
112-
# These are default paths that will always be registered even if you override
113-
# the setting and don't repeat them:
11494
#anonymizer_paths:
11595
#- ./src/Anonymization/Anonymizer'
11696

97+
# Data anonymization configuration.
11798
anonymization:
11899
# From here you can proceed with manual file inclusion. Pathes can be
119100
# either relative or absolute. Relative paths are relative to the workdir
120101
# option if specified, or from this configuration file directory
121102
# otherwise.
103+
104+
# Each connection can have its configuration file. The configuration file
105+
# structure is identical to the "table" section of the YAML, ommiting the
106+
# "table" top-level key.
107+
108+
# See the "anonymizations.sample.yaml" in this folder for an example.
109+
110+
# If you want to load configuration from a yaml. If you have a single
111+
# connection, you may omit the connection name and declare the file name
112+
# this way:
113+
#yaml: '%kernel.project_dir%/config/anonymizations.yaml'
114+
115+
# Alternatively if you have many connection, you can import a file for
116+
# each connection using this syntax:
122117
yaml:
123118
connection_one: ./db_tools.anonymizer.connection_one.yaml
124119
# ... other connections ...
125120

126-
# Extra configuration options, if you don't want to split the anonymization
127-
# configuration into multiple files, you can directly write it here.
121+
# If you do not wish to split the configuration into tables, you can
122+
# write all your table configuration directly here.
123+
# Keys are connection names, values must follow the structure of the
124+
# individual YAML files as presented above.
128125
tables:
129126
connection_one:
130127
# From here, please refer to 'anonymizations.sample.yaml' for sample
@@ -135,3 +132,4 @@ anonymization:
135132
# ... other options...
136133
connection_two:
137134
# ...
135+

0 commit comments

Comments
 (0)