跪拜 Guibai
← Back to the summary

dbswitch: Offline Bulk Migration to Nearly 30 Databases, DDL Auto-Generated

01 Introduction

The previous article covered a database sync tool called DBSyncer. In the past couple of days I spotted another open source project on Gitee — dbswitch — with similar functionality. It's also a project under the domestic community dromara. Let's take a look at how this project holds up!

02 Overview

dbswitch is a member project of the Dromara open source community, developed entirely in Java, released under the BSD open source license. The dbswitch tool provides offline batch migration and sync from source databases to destination databases, supporting full, incremental, and changed-data (CDC) sync.

It was born out of two major scenarios: data movement between databases and data ingestion into warehouses or data lakes. Core capabilities:

Gitee address: https://gitee.com/dromara/dbswitch

03 Installation and deployment

Environment requirements: JDK >= 1.8, Maven >= 3.6 (if building from source). After building, dbswitch-release-x.x.x.tar.gz is generated in the target/ directory; copy it to a machine with JRE installed and extract. For most people, Docker is the easiest route. Official images support multiple configuration-store modes.

3.1 Build and package

Windows:

Double-click the build.cmd script to compile and package

Linux:

git clone https://gitee.com/inrgihc/dbswitch.git
cd dbswitch/
sh ./build.sh

Docker:

git clone https://gitee.com/inrgihc/dbswitch.git
cd dbswitch/
sh ./docker-maven-build.sh

3.2 Docker deployment

docker deployment supports different config backends: h2, Mysql, PostgreSQL, OpenGauss.

Set via the DBTYPE parameter. Using Mysql as an example:

docker run -d --name dbswitch \
 -e DBTYPE=mysql \
 -e MYSQLDB_HOST=127.0.0.1 \
 -e MYSQLDB_PORT=3306 \
 -e MYSQLDB_USERNAME=root \
 -e MYSQLDB_PASSWORD='root' \
 -e MYSQLDB_NAME='dbswitch' \
 -v /tmp:/tmp \
 -p 9088:9088 \
 registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:2.0.1

04 Hands-on

We'll use Docker deployment as the example.

Then visit IP + port to see the Web page. Account/password: admin/123456

Dashboard:

4.1 Adding a data source

Supported data sources:

Add connection:

Connection list:

4.2 Migration tasks

Add task information

Source configuration:

Target configuration:

Task list:

From the configuration, sync can only run via scheduled tasks. This isn't friendly for scenarios with high real-time requirements. Testing shows the minimum interval for scheduled tasks is 120s.

4.3 Starting tasks

You can check the dashboard or the scheduled tasks view.

05 Summary

dbswitch compensates for DBSyncer's automatic table creation gap, but its near-real-time (120s) limitation may be the biggest drawback for many scenarios. If you like tinkering, give it a try.

Comments

Top 2 of 4 from juejin.cn, machine-translated. The original thread is authoritative.

摸鱼办岳主任

Have been using it for a few days.

SimonKing

It can't sync in real time, can you tolerate that? [chuckle]

摸鱼办岳主任  → SimonKing

I use it for database backup; I only run it once a day.

VallainMing

I've used Kingbase's kdts; there were failures migrating functions and views.