Fast MySQL dump tool that excludes noisy data while preserving complete database structure.
Using dbdump from an agent or automation? Start with the deployed llms.txt for a concise, non-interactive setup and safety guide.
When dumping production databases for development, you often don't need millions of audit log entries, session data, or cache records. These tables can make dumps take hours and consume gigabytes of space.
dbdump solves this by:
- Excluding data from noisy tables (audits, sessions, cache, etc.)
- Preserving every table definition, including foreign-key constraints
- Reducing work in proportion to the rows excluded
- Making development database refreshes practical
brew install helgesverre/tap/dbdumpUpgrade later with brew upgrade helgesverre/tap/dbdump. Available for macOS and Linux (Intel and Apple Silicon / ARM64).
If you have Go 1.26+ installed:
go install github.com/helgesverre/dbdump/cmd/dbdump@latestDownload the matching versioned asset from the releases page. Asset names include the tag, for example dbdump-v1.2.0-darwin-arm64.tar.gz.
curl -LO https://github.com/helgesverre/dbdump/releases/download/vX.Y.Z/dbdump-vX.Y.Z-darwin-arm64.tar.gz
tar -xzf dbdump-vX.Y.Z-darwin-arm64.tar.gz
chmod +x dbdump-darwin-arm64
sudo mv dbdump-darwin-arm64 /usr/local/bin/dbdumpcurl -LO https://github.com/helgesverre/dbdump/releases/download/vX.Y.Z/dbdump-vX.Y.Z-darwin-amd64.tar.gz
tar -xzf dbdump-vX.Y.Z-darwin-amd64.tar.gz
chmod +x dbdump-darwin-amd64
sudo mv dbdump-darwin-amd64 /usr/local/bin/dbdumpcurl -LO https://github.com/helgesverre/dbdump/releases/download/vX.Y.Z/dbdump-vX.Y.Z-linux-amd64.tar.gz
tar -xzf dbdump-vX.Y.Z-linux-amd64.tar.gz
chmod +x dbdump-linux-amd64
sudo mv dbdump-linux-amd64 /usr/local/bin/dbdumpcurl -LO https://github.com/helgesverre/dbdump/releases/download/vX.Y.Z/dbdump-vX.Y.Z-linux-arm64.tar.gz
tar -xzf dbdump-vX.Y.Z-linux-arm64.tar.gz
chmod +x dbdump-linux-arm64
sudo mv dbdump-linux-arm64 /usr/local/bin/dbdumpDownload the versioned Windows asset from the releases page, extract dbdump-windows-amd64.exe, rename it to dbdump.exe, and place it on your PATH.
dbdump --help- MySQL client tools -
mysqldumpmust be in your PATH (comes with MySQL client)- macOS:
brew install mysql-client - Ubuntu/Debian:
sudo apt-get install mysql-client - CentOS/RHEL:
sudo yum install mysql
- macOS:
git clone https://github.com/helgesverre/dbdump.git
cd dbdump
just installjust install builds and installs to ~/.local/bin (no sudo); pass a
destination to override, e.g. just install /usr/local/bin. Ensure the target
directory is on your PATH.
Requires Go 1.26+ and just.
# Recommended: Use environment variable for password
export DBDUMP_MYSQL_PWD=yourpassword
dbdump dump -H localhost -u root -d mydb
# Or provide password as flag (less secure)
dbdump dump -H localhost -u root -p password -d mydbThis will:
- Connect to your database
- Show all tables with sizes
- Pre-select noisy tables based on patterns
- Let you customize the selection
- Dump structure for all tables, data for selected tables
dbdump dump -H localhost -u root -d mydb --autoUses smart defaults without interaction.
dbdump dump -H localhost -u root -d mydb --config ./project.yaml# Set password securely via environment variable
export DBDUMP_MYSQL_PWD=yourpassword
# Dump database (interactive)
dbdump dump -H localhost -u root -d mydb
# List tables with sizes
dbdump list -H localhost -u root -d mydb
# Non-interactive dry run (see what would be excluded)
dbdump dump -H localhost -u root -d mydb --auto --dry-run
# Dump with custom output file
dbdump dump -H localhost -u root -d mydb -o backup.sql
# Dump with streaming compression
dbdump dump -H localhost -u root -d mydb --auto --compress gzip
# Dump through an SSH bastion
dbdump dump -H 127.0.0.1 -P 3306 -u root -d mydb \
--ssh-host bastion.example.com \
--ssh-user deploy-H, --host Database host (default: 127.0.0.1)
-P, --port Database port (default: 3306)
-u, --user Database user
-p, --password Database password (or use DBDUMP_MYSQL_PWD/MYSQL_PWD env)
-d, --database Database name
--profile Load connection settings from a saved profile (see `dbdump config`) --tls-mode TLS mode: disabled, preferred, require, verify-ca, verify-identity
--tls-ca Path to the TLS CA certificate (PEM) used to verify the server
--tls-cert Path to the client certificate (PEM) for mutual TLS
--tls-key Path to the client private key (PEM) for mutual TLS
--tls-skip-verify Encrypt but skip server certificate verification (insecure)
--tls-server-name Override the hostname verified against the server certificate-o, --output Output file (default: {database}_{timestamp}.sql)
-c, --config Config file path
--exclude Exclude specific table data (repeatable)
--exclude-pattern Exclude tables matching pattern (repeatable)
--include Keep this table's data even when a rule excludes it (repeatable)
--auto Use smart defaults without interaction
--dry-run Show what would be dumped without dumping
--compress Compression format: auto, none, gzip, zstd
--ssh-host SSH bastion host for tunneling to the database
--ssh-port SSH bastion port (default: 22)
--ssh-user SSH username (defaults to database user)
--ssh-key SSH private key path
--ssh-local-port Local port for the SSH tunnel (default: auto)dbdump can stream output as plain SQL, gzip, or zstd. --compress auto infers the format from the output filename, while explicit formats override filename inference.
If you omit --output, compressed dumps use matching default names such as mydb_20260331_120000.sql.gz or mydb_20260331_120000.sql.zst.
You can still create a manual tunnel yourself, but dbdump can now manage it directly:
dbdump dump -H 127.0.0.1 -P 3306 -u root -d mydb \
--ssh-host bastion.example.com \
--ssh-user deploy \
--ssh-key ~/.ssh/id_ed25519 \
--autoWhen SSH tunneling is enabled, -H/--host and -P/--port still describe the database endpoint as seen from the SSH server.
dbdump can connect over TLS, applied to both its own inspection connection and the mysqldump subprocess:
# Encrypt and verify the server against a CA
dbdump dump -H db.example.com -u readonly -d myapp \
--tls-mode verify-identity --tls-ca /etc/ssl/certs/ca.pem --auto
# Mutual TLS (client certificate)
dbdump dump -H db.example.com -u readonly -d myapp \
--tls-mode verify-ca --tls-ca ca.pem --tls-cert client.pem --tls-key client-key.pem --auto
# Encrypt only, skip verification (dev / self-signed)
dbdump dump -H localhost -u root -d mydb --tls-mode require --tls-skip-verify --autoModes mirror MySQL's ssl-mode: disabled, preferred (opportunistic), require (encrypt, no verification), verify-ca (verify the chain), and verify-identity (verify the chain and hostname). An explicit disabled mode ignores certificate options and remains plaintext. Because custom certificates cannot preserve opportunistic fallback consistently across both clients, combine them with require, verify-ca, or verify-identity, not preferred. Behind an SSH tunnel the host becomes 127.0.0.1, so use --tls-server-name to pin the real certificate name. With no --tls-* flag, connections behave exactly as before.
# Use environment variable for password
export DBDUMP_MYSQL_PWD=secret
dbdump dump -H prod.example.com -u readonly -d myapp_prod
# Exclude specific tables
dbdump dump -H localhost -u root -d mydb \
--exclude audits \
--exclude activity_logs \
--exclude-pattern "temp_*"
# With project config
dbdump dump -H localhost -u root -d mydb --config ./myproject.yaml
# Auto mode with custom output
dbdump dump -H localhost -u root -d mydb --auto -o daily-backup.sql
# Auto mode with gzip output
dbdump dump -H localhost -u root -d mydb --auto --compress gzip
# Remote dump through SSH
dbdump dump -H 127.0.0.1 -P 3306 -u root -d mydb \
--ssh-host bastion.example.com \
--ssh-user deploy \
--autodbdump supports multiple configuration layers that merge together:
- Built-in defaults (always applied)
- Global user config (
~/.dbdump.yaml) - optional, applies to all dumps - Project config (via
--configflag) - optional, project-specific - CLI flags (highest priority)
For a comprehensive guide, see USER-GUIDE.md.
Create ~/.dbdump.yaml for settings that apply to all your dumps:
name: "My Global Config"
exclude:
exact:
- activity_logs
- user_sessions
patterns:
- "temp_*"
- "*_backup"Create a project.yaml file in your project:
name: "My Project"
exclude:
exact:
- audits
- activity_logs
- custom_noisy_table
patterns:
- "temp_*"
- "*_cache"
- "old_*"Use it with:
dbdump dump -H localhost -u root -d mydb --config ./project.yamldbdump includes smart defaults for common Laravel tables:
Exact matches:
- activity_log
- audits
- sessions
- cache
- cache_locks
- failed_jobs
- telescope_entries
- telescope_entries_tags
- telescope_monitoring
- pulse_entries
- pulse_aggregates
Patterns:
telescope_*pulse_**_cache
These defaults are always applied. Later layers can add more excludes. Use --include <table> to override any matching rule.
dbdump writes the dump in three phases:
-
Phase 1: Structure Dump
- Dumps complete schema for ALL tables
- Preserves foreign-key definitions and other table relationships
- Uses
mysqldump --no-data --skip-triggers
-
Phase 2: Data Dump
- Dumps data for all tables EXCEPT excluded ones
- Uses
mysqldump --no-create-info --ignore-table=...
-
Phase 3: Triggers
- Writes trigger definitions after the data so loading rows does not fire them
- Uses
mysqldump --no-data --no-create-info --triggers
Result: A complete database dump with empty noisy tables.
The savings depend on how much of the source database is in excluded tables.
Applications dominated by audit logs, sessions, caches, or telemetry benefit the
most: dbdump retains those tables' definitions while omitting their rows. Run
dbdump list, followed by dbdump dump --auto --dry-run, to estimate the impact
for your database before creating a dump.
- USER-GUIDE.md - Comprehensive user guide with detailed configuration, examples, and troubleshooting
- CHANGELOG.md - Version history
- TESTING_GUIDE.md - Complete testing documentation
- BENCHMARKING.md - Performance testing guide
# Build for current platform
just build
# Build for all platforms
just build-all
# Run tests
just test
# Format code
just fmt# Run the full integration test suite (starts Docker Compose locally)
./test/integration-test.sh
# Cleanup
docker compose -f docker/docker-compose.yml down -vSee test/README.md for detailed testing documentation.
# Test security (password not in process list)
export DBDUMP_MYSQL_PWD=testpass123
./bin/dbdump dump -H 127.0.0.1 -P 3308 -u root -d testdb --auto
ps aux | grep dbdump # Should NOT show password
# Verify file permissions (should be 0600)
ls -la testdb_*.sql
# Test data integrity (triggers and events are included; routines are intentionally omitted)
grep -i "CREATE TRIGGER" testdb_*.sql
grep -i "CREATE EVENT" testdb_*.sqldbdump/
├── cmd/dbdump/ # CLI entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── database/ # Database operations
│ ├── patterns/ # Pattern matching
│ └── ui/ # Interactive UI
├── configs/ # Example configurations
└── justfile # Build commands
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
- Built with Cobra for CLI
- Interactive UI using Bubble Tea
- Font: Monda
- Icon: Remix Icon
- Colors:
- Dark:
#0F172A - Icon:
#F9FAFB - Text:
#FFFFFF
- Dark:
