Skip to main content
High-Performance Databases

Multi-Gigabyte Database Migration Strategies

Zero-lock database migration protocols for multi-hundred gigabyte MySQL, MariaDB, and PostgreSQL workloads. Eliminate read locks, query timeouts, and data divergence.

12 min read
Updated: September 2026
InnoDB & Galera Cluster Ready
migration / xtrabackup-stream
root@db-cluster-01:~# xtrabackup --backup --stream=xbstream --parallel=4 /tmp/db | ssh target-db 'xbstream -x -C /var/lib/mysql/'
xtrabackup: Processing 462 GB InnoDB tablespaces without read locks...
xtrabackup: Transaction log copied to lsn: 89401294821
root@db-cluster-01:~# xtrabackup --prepare --target-dir=/var/lib/mysql/
InnoDB: Starting recovery from checkpoint. Tables ready for replica catch-up.
root@db-cluster-01:~# pt-table-checksum --databases=prod_commerce --quiet
0 differences detected across 1,280 tables. 100% data consistency verified.
root@db-cluster-01:~#
Quick Answer / Executive Summary

Multi-gigabyte database migration without locking is executed based on dataset size: for databases under 50 GB, stream mysqldump --single-transaction --quick over an encrypted SSH pipe; for 50 GB to 200 GB, utilize multi-threaded MyDumper to chunk tables; and for databases exceeding 200 GB, use Percona XtraBackup to take physical hot snapshots and seed real-time master-slave replication channels for a sub-30-second cutover.

The Database Scaling Dilemma: Why Naive Dumps Crash Production

When databases grow beyond 20 GB to 50 GB, standard backup tools like default mysqldump become hazardous. A default dump issues table-level locks (FLUSH TABLES WITH READ LOCK) that freeze application writes. In active web applications, incoming checkout requests and user transactions queue up until PHP-FPM workers exhaust their max limits, causing cascade 504 Gateway Timeouts.

Furthermore, exporting a 500 GB database to an uncompressed SQL file on disk requires doubling local storage, followed by an agonizingly slow restoration that can take 12 to 24 hours while re-indexing keys. Professional database migrations require non-blocking, multi-threaded, or physical stream replication techniques.

Small (< 30 GB)
Piped mysqldump

Direct stream using single-transaction flags and pigz compression over SSH pipes.

Medium (30 - 200 GB)
MyDumper / MyLoader

Multi-threaded logical dumps splitting massive tables into parallel chunks.

Large (> 200 GB)
Percona XtraBackup

Physical hot copy of raw InnoDB data files with real-time replication catchup.

3 Field-Tested Database Migration Strategies

Strategy 1: Compressed SSH Streaming (mysqldump --single-transaction)

For pure InnoDB databases under 50 GB, stream the dump directly from the source server to the destination server over SSH without writing any intermediate files to disk. The --single-transaction flag uses InnoDB snapshot isolation (MVCC) to read consistent data without locking tables.

# Stream dump directly to destination MySQL instance
mysqldump --single-transaction --quick --max-allowed-packet=512M \
  --routines --triggers --databases dbname | \
  ssh target-ip "mysql --max-allowed-packet=512M dbname"

Strategy 2: Multi-Threaded Chunking with MyDumper

When dealing with tables that contain hundreds of millions of rows, single-threaded dumps bottleneck on a single CPU core. MyDumper splits large tables into manageable row chunks and dumps them concurrently across 8 or 16 threads, speeding up export and import by up to 8x compared to mysqldump.

Strategy 3: Master-Slave Replication Cutover (The Gold Standard)

For databases exceeding 200 GB where even 10 minutes of cutover downtime is unacceptable, configure the destination server as a live MySQL read replica. Take an initial snapshot with Percona XtraBackup, record the binary log coordinates, restore the snapshot on the target, and start the replication channel (CHANGE MASTER TO).

During cutover: enable read-only mode on the source, verify Seconds_Behind_Master = 0 on the replica, promote the target server to primary master, and switch application database credentials. Total cutover time: under 30 seconds.

Pre-Migration Database Optimization Checklist

Buffer Pool Pre-Allocation: Configure innodb_buffer_pool_size to 70-80% of total system RAM on the target server to accelerate page caching during import.
Redo Log Sizing: Temporarily set innodb_doublewrite = 0 and increase innodb_redo_log_capacity during the initial import to maximize sequential write throughput.
Foreign Key Checks: Ensure SET FOREIGN_KEY_CHECKS=0; is included in import headers to avoid dependency order deadlocks during table population.
Data Integrity Verification: Run Percona Toolkit's pt-table-checksum across key tables to verify identical row counts and data hashes post-migration.
Infrastructure Support

Migrate Your Multi-Gigabyte Databases With Zero Loss

Protect transactions, user records, and analytical data with certified database administrators managing your migration pipeline.