Synchronize a database from and to client systems.
Project description
Database Sync Tool
Python script to synchronize a database from an origin to a target system.
Supported framework types:
- TYPO3 (>= v7.6)
- Symfony (>= v3.4)
Prerequisite
The script needs python 3.7 or higher. It is necessary for some additional functionalities to have pip installed on your local machine.
Installation
pip
The library can be installed from PyPI:
$ pip3 install db-sync-tool-kmi
composer
While using the script within the PHP framework context, the script is available via packagist.org using composer:
$ composer require kmi/db-sync-tool
Additionally install the python requirements via the following pip command:
$ pip3 install -r vendor/kmi/db-sync-tool/requirements.txt
Configuration
The config.json
contains important information about the origin and the target system. In dependence on the given configuration the synchronisation mode is implicitly selected.
# Copy/edit host.json for TYPO3
$ cp docs/dist/t3-db-sync.json.dist config.json
# Copy/edit host.json for Symfony
$ cp docs/dist/sf-db-sync.json.dist config.json
Example structure of config.json
for a Symfony system in receiver mode:
{
"name": "project",
"type": "Symfony",
"target": {
"path": "/var/www/html/app/.env"
},
"origin": {
"host": "ssh_host",
"user": "ssh_user",
"path": "/var/www/html/project/shared/.env"
},
"ignore_table": []
}
Adjustments
It is possible to adjust the config.json
configuration.
Sync modes
The script provides seven different kinds of synchronisation modes.
- Receiver
- Sender
- Proxy
- Dump Local
- Dump Remote
- Import Local
- Import Remote
Usage
Run the python script:
$ python3 db_sync_tool/sync.py
# Options
-h, --help Show help
-v, --verbose Enable extended console output
-f, --file Path to host file
-i, --importfile Import database from a specific file dump
-dn, --dumpname Set a specific dump file name (default is "_[dbname]_[date]")
-kd, --keepdump Skipping target import of the database dump and saving the available dump file in the given directory
-o, --hosts Using an additional hosts file for merging hosts information with the configuration file
If you haven't declare a path to a SSH key, during the script execution you are requested to enter the SSH password for the given user in the host.json
to enable a SSH connection to the remote system.
Build
The packaging process of the python module is described on python.org.
Tests
A docker container set up is available for testing purpose. See here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for db_sync_tool_kmi-1.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | caf590e1252044cef63e915e77eef1bf77332bd40041c85dc9c25720ae828a69 |
|
MD5 | fc2df6ca417de47f322649961e444409 |
|
BLAKE2b-256 | 194b0c332b67fb988afa22dd1ba93fe3a4e231b3cc1664c59edf47ed704911bd |