dbcopy
is a database copy- and migration tool. It is used by the Volkszaehler project.
dbcopy
is configured via a dbcopy.json
config file. dbcopy
will look for this file in the following places if not specified using the --config
option:
dbcopy
itselfThe config file has the following structure:
{
"source": {
// source database connection
"driver": "pdo_mysql",
"host": "localhost",
"user": "travis",
"password": "",
"dbname": "volkszaehler"
},
"target": {
// target database connection
"driver": "pdo_sqlite",
"path": "sqlite.db3", // path is only used if driver = pdo_sqlite
"host": "localhost",
"user": "travis",
"password": ""
// "dbname": "backup"
},
"tables": [
// table configuration (optional)
// ------------------------------
// table name
// tables will be processed in the order they are mentioned:
// - foreign keys on target will be dropped
// - if a table is not listed here, it will not be touched
// transfer mode
// skip: table will not be copied
// copy: entire table will be truncated on target and copied from source
// pk: selective copy by primary key. only data not present on target
// will be copied from source.
{
"name": "table_1",
"mode": "copy"
},
...
]
}
The tables
section is optional. If not configured, dbcopy
will auto-discover all tables in the source schema.
>./dbcopy
Database backup tool
Usage:
[options] command [arguments]
Options:
--help (-h) Display this help message.
Available commands:
backup Run backup
clear Clear target tables
create Create target schema
drop Drop target schema
help Displays help for a command
influx Copy data to InfluxDB
list Lists commands
The create
command will copy the database schema of the source database connection to the target database. If database drivers (e.g. MySQL and SQlite) differ, the schema definition will be translated for the target platform. Limits of the underlying Doctrine/DBAL libraries apply.
The clear
command clears all tables in the target schema by TRUNCATING them. With the --drop
option the tables are DROPPed altogether.
Opposed to clear
, the drop
command DROPs the entire target schema if the database platforms supports it. If e.g. SQlite is used, the SQlite database file is not deleted.
backup
is the core routine of dbcopy
. backup
executes the following steps:
The influx
command can copy data from the Volkszaehler data table into an InfluxDB measurement. This can be helpful for using Grafana or Chronograf with Volkszaehler.
With this command, the table configuration is ignored and only the data table transferred, including additional entity attributes.
dbcopy
does not support triggers and stored procedures. No support is planned.