项目作者: pascalgn

项目描述 :
Database migration tool
高级语言: Kotlin
项目地址: git://github.com/pascalgn/dbmigration.git
创建时间: 2017-07-16T19:29:12Z
项目社区:https://github.com/pascalgn/dbmigration

开源协议:Apache License 2.0

下载


Database migration tool

Build Status
License

A tool to export data from one SQL database and import it into another.

Usage

  1. mkdir /tmp/db
  2. vim /tmp/db/migration.properties
  3. java com.github.pascalgn.dbmigration.Main migrate /tmp/db

Configuration

If no configuration file can be found, a default configuration file will be written.
See migration-defaults.properties for more information.

JDBC drivers

Standard JDBC will be used to access the databases.

The following drivers have been tested to work:

SSH tunnel

To connect to a database through an SSH tunnel, use the following command:

  1. # forwards 127.0.0.1:12345 to sql-server:1433
  2. ssh -N user@ssh-server -L 127.0.0.1:12345:sql-server:1433

Make sure to also change your migration configuration accordingly:

  1. ...
  2. # host and port need to be separated by comma for MS SQL
  3. source.jdbc.url=jdbc:sqlserver://127.0.0.1,12345;database=dbname
  4. ...

Docker image

This tool is also available as a docker image:

  1. $ mkdir /tmp/db
  2. $ vim /tmp/db/migration.properties
  3. $ docker run -v /tmp/db:/home/dbmigration/data pascalgn/dbmigration \
  4. migrate /home/dbmigration/data

You can use the LOG_LEVEL environment variable to change the log output:

  1. $ docker run -e LOG_LEVEL=debug -v /tmp/db:/home/dbmigration/data pascalgn/dbmigration

The default level is info. For more information, see the Dockerfile.

Binary format

The exported files are gzip compressed and written in the following format:

  1. <content> ::= <version> <table-name> <columns> <rows>
  2. <version> ::= "3"
  3. <table-name> ::= <text>
  4. <columns> ::= <column-count> { <column-name> <column-sql-type> }
  5. <column-count> ::= int
  6. <column-name> ::= <text>
  7. <column-sql-type> ::= int
  8. <rows> ::= { "1" <row> }
  9. ; each row contains exactly <column-count> entries
  10. <row> ::= { <row-column> }
  11. <row-column> ::= "0" | "1" ( <text> | <number> | <length> bytes | <date> )
  12. <text> ::= <length> utf8-encoded-bytes
  13. <length> ::= int
  14. <number> ::= <scale> <length> bytes
  15. <scale> ::= int
  16. ; dates are represented as milliseconds since January 1, 1970
  17. <date> ::= long

Note that the exported files may consist of multiple gzip member entries.

License

This database migration tool is licensed under the Apache License, Version 2.0