https://github.com/pascalgn/dbmigration
Database migration tool
https://github.com/pascalgn/dbmigration
data-migration database-migrations migration sql
Last synced: 11 months ago
JSON representation
Database migration tool
- Host: GitHub
- URL: https://github.com/pascalgn/dbmigration
- Owner: pascalgn
- License: apache-2.0
- Created: 2017-07-16T19:29:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-02T17:49:34.000Z (about 8 years ago)
- Last Synced: 2025-02-10T15:50:51.038Z (about 1 year ago)
- Topics: data-migration, database-migrations, migration, sql
- Language: Kotlin
- Homepage:
- Size: 117 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Database migration tool
[](https://travis-ci.org/pascalgn/dbmigration)
[](LICENSE)
A tool to export data from one SQL database and import it into another.
## Usage
mkdir /tmp/db
vim /tmp/db/migration.properties
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](src/main/resources/com/github/pascalgn/dbmigration/migration-defaults.properties) for more information.
### JDBC drivers
Standard [JDBC](https://en.wikipedia.org/wiki/Java_Database_Connectivity) will be used to access the databases.
The following drivers have been tested to work:
- [H2](http://repo2.maven.org/maven2/com/h2database/h2/1.4.192/)
- [MS SQL](http://repo2.maven.org/maven2/com/microsoft/sqlserver/mssql-jdbc/6.1.0.jre8/)
- [Oracle](http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html) (registration required)
### SSH tunnel
To connect to a database through an SSH tunnel, use the following command:
# forwards 127.0.0.1:12345 to sql-server:1433
ssh -N user@ssh-server -L 127.0.0.1:12345:sql-server:1433
Make sure to also change your migration configuration accordingly:
...
# host and port need to be separated by comma for MS SQL
source.jdbc.url=jdbc:sqlserver://127.0.0.1,12345;database=dbname
...
## Docker image
This tool is also available as a [docker image](https://hub.docker.com/r/pascalgn/dbmigration/):
$ mkdir /tmp/db
$ vim /tmp/db/migration.properties
$ docker run -v /tmp/db:/home/dbmigration/data pascalgn/dbmigration \
migrate /home/dbmigration/data
You can use the `LOG_LEVEL` environment variable to change the log output:
$ 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](src/build/Dockerfile).
## Binary format
The exported files are gzip compressed and written in the following format:
::=
::= "3"
::=
::= { }
::= int
::=
::= int
::= { "1" }
; each row contains exactly entries
::= { }
::= "0" | "1" ( | | bytes | )
::= utf8-encoded-bytes
::= int
::= bytes
::= int
; dates are represented as milliseconds since January 1, 1970
::= long
Note that the exported files may consist of multiple [gzip member](https://tools.ietf.org/html/rfc1952#page-5) entries.
## License
This database migration tool is licensed under the Apache License, Version 2.0