Skip to main content

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:

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

Command line

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.

Import

You can import the python package and use them inside your project:

import db_sync_tool

if __name__ == "__main__":
    db_sync_tool.Sync(args, config)

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

db_sync_tool-kmi-2.0.1.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

db_sync_tool_kmi-2.0.1-py3-none-any.whl (37.1 kB view details)

Uploaded Python 3

File details

Details for the file db_sync_tool-kmi-2.0.1.tar.gz.

File metadata

  • Download URL: db_sync_tool-kmi-2.0.1.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

File hashes

Hashes for db_sync_tool-kmi-2.0.1.tar.gz
Algorithm Hash digest
SHA256 8e6e78c3adcd3e0349ce4b618c50bc457a5c39bb56774d109b44fb0412cff641
MD5 61e5db6c7a3f10d6d01d1602f7a80105
BLAKE2b-256 9526d02fbc0d2a82a395d87d71617a64fafc247eaebd3a9992682d7ac5e07c1e

See more details on using hashes here.

File details

Details for the file db_sync_tool_kmi-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: db_sync_tool_kmi-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 37.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

File hashes

Hashes for db_sync_tool_kmi-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 905d09b916d4d872025fc0e8de96f438d50dd501b918f8d3af36ea8e5207243f
MD5 27a7be50e55c57830990bf6a5fc30e1a
BLAKE2b-256 0ffb45120aaaec09248a93c2a51f2b8ea2d4c14c4ca464f62b8f2e0a3ada7f57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page