A Shopware 6 plugin for syncing databases from staging/production environments to your local development environment via SSH.
- Sync from staging or production environments
- SSH connection support with key authentication
- Automatic database dump, download, and import
- Table filtering for performance and GDPR compliance
- Local environment overrides (URLs, domains, system config)
- Post-sync console commands (e.g. deactivate plugins, create users)
- Apply config overrides without a full sync (
--apply-config-only) - DDEV compatible
composer require sidworks/sw-plugin-database-sync --dev
bin/console plugin:refresh
bin/console plugin:install --activate SidworksDatabaseSync
bin/console cache:clear- Clone or download this repository to
custom/plugins/SidworksDatabaseSync - Run the following commands:
bin/console plugin:refresh
bin/console plugin:install --activate SidworksDatabaseSync
bin/console cache:clearAdd the following to your .env.local file:
# Staging Environment
SW_DB_SYNC_STAGING_HOST=your-staging-server.com
SW_DB_SYNC_STAGING_USER=your-username
SW_DB_SYNC_STAGING_PORT=22
SW_DB_SYNC_STAGING_PROJECT_PATH=/var/www/html
SW_DB_SYNC_STAGING_KEY=~/.ssh/id_ed25519 # Optional: SSH key path
# Production Environment
SW_DB_SYNC_PRODUCTION_HOST=your-production-server.com
SW_DB_SYNC_PRODUCTION_USER=your-username
SW_DB_SYNC_PRODUCTION_PORT=22
SW_DB_SYNC_PRODUCTION_PROJECT_PATH=/var/www/html
SW_DB_SYNC_PRODUCTION_KEY=~/.ssh/id_ed25519 # Optional: SSH key path
# Local overrides
SW_DB_SYNC_LOCAL_DOMAIN=your-project.ddev.site
SW_DB_SYNC_DOMAIN_MAPPINGS=production.com:your-project.ddev.site,staging.com:your-project.ddev.site
SW_DB_SYNC_CLEAR_CACHE=true # Set to "false" to skip cache clearing| Variable | Description |
|---|---|
SW_DB_SYNC_[ENV]_HOST |
Hostname or IP address of the server |
SW_DB_SYNC_[ENV]_USER |
SSH username |
SW_DB_SYNC_[ENV]_PORT |
SSH port (default: 22) |
SW_DB_SYNC_[ENV]_PROJECT_PATH |
Remote Shopware project directory path |
| Variable | Description |
|---|---|
SW_DB_SYNC_[ENV]_KEY |
Path to SSH private key (supports ~/ expansion) |
SW_DB_SYNC_LOCAL_DOMAIN |
Default local domain for URL overrides |
SW_DB_SYNC_DOMAIN_MAPPINGS |
Comma-separated from:to domain mappings |
SW_DB_SYNC_CLEAR_CACHE |
Clear cache after sync — true (default) or false |
Replace [ENV] with either STAGING or PRODUCTION.
Create a sw-db-sync-config.json file in your Shopware root directory:
cp vendor/sidworks/sw-plugin-database-sync/sw-db-sync-config.json.example sw-db-sync-config.json
nano sw-db-sync-config.jsonWhen this file exists, it takes priority over environment variable domain mappings.
Tables to skip during the data dump. The example file includes 62 commonly ignored tables covering:
Performance tables (always recommended):
enqueue— Message queueproduct_keyword_dictionary— Search keywordsproduct_search_keyword— Search indexlog_entry— Application logsmessage_queue_stats— Queue statisticselasticsearch_index_task— Search indexingstate_machine_history— Order/payment state history
GDPR/Privacy tables (customer and order data):
customer,customer_address,customer_tag,customer_wishlistorder,order_address,order_delivery,order_line_item,order_transactioncart— Shopping cartsuser,user_config,user_recovery,user_access_key— Admin usersnewsletter_recipient,newsletter_recipient_tag- Payment plugin tables (Klarna, Payone, Pay.nl, Unzer)
Tip: Remove tables from the list if you need them in development. For example, keep user if you need existing admin accounts.
Map sales channel IDs to local domains. Find your sales channel IDs with:
SELECT LOWER(HEX(id)) as id, name FROM sales_channel;{
"sales_channel_domains": {
"018d5f1e5e7e7f1e8b8d5f1e5e7e7f1e": "https://your-project.ddev.site"
}
}Update Shopware system configuration values after import:
{
"system_config": {
"core.basicInformation.email": "local@example.com",
"core.mailerSettings.host": "localhost",
"core.mailerSettings.port": "1025"
}
}Values that don't exist yet are automatically inserted.
Execute raw SQL statements after import. Use with caution:
{
"sql_updates": [
"UPDATE sales_channel_domain SET url = REPLACE(url, 'production.com', 'ddev.site')"
]
}Console commands to run after the sync completes. Failed commands produce warnings but don't abort the process:
{
"post_sync_commands": [
"user:create admin -a --email info@example.com -p thisIsMyPassword",
"plugin:refresh",
"plugin:install SidworksDatabaseSync -a",
"theme:compile"
]
}Common use cases:
- Create a local admin user after importing (since
usertable is typically ignored) - Deactivate production-only plugins or apps
- Refresh and reinstall the sync plugin itself after import
- Recompile themes
| Method | Use case |
|---|---|
Environment variables (.env.local) |
Simple domain mappings, basic setups |
Config file (sw-db-sync-config.json) |
Advanced overrides, system config, SQL updates, post-sync commands |
If sw-db-sync-config.json exists, it takes priority over environment variable domain mappings.
bin/console sidworks:db:sync stagingbin/console sidworks:db:sync production| Option | Description |
|---|---|
--keep-dump, -k |
Keep the dump file in the project root after import |
--skip-import |
Only download the dump, don't import |
--no-gzip |
Don't compress the dump (faster for small databases) |
--skip-overrides |
Skip applying local environment overrides |
--no-ignore |
Dump all tables (don't ignore any) |
--apply-config-only[=path] |
Only apply config file overrides without syncing |
--skip-cache-clear |
Skip clearing cache after applying configuration |
--skip-post-commands |
Skip running post-sync commands |
Re-apply your sw-db-sync-config.json overrides without downloading a new database dump. Useful after manual database changes or when you just need to update system config:
# Use default sw-db-sync-config.json
bin/console sidworks:db:sync --apply-config-only
# Use a custom config file
bin/console sidworks:db:sync --apply-config-only=custom-config.json
# Use an absolute path
bin/console sidworks:db:sync --apply-config-only=/path/to/config.json
# Apply config only, skip cache clear and post-sync commands
bin/console sidworks:db:sync --apply-config-only --skip-cache-clear --skip-post-commandsShow which tables are being ignored:
bin/console sidworks:db:sync staging -vIf you're using DDEV, forward your SSH agent first:
ddev auth sshThen run the sync command inside the container:
ddev exec bin/console sidworks:db:sync staging- Validate configuration — Check required SSH and environment settings
- Fetch remote environment — Read database credentials from the remote server via SSH (supports
.env.local.php,.env.local, and.env) - Create remote dump — Two-step mysqldump (structure + data) on the remote server
- Download dump — Transfer the compressed dump via rsync
- Cleanup remote — Delete the dump file from the remote server
- Import database — Import dump into local database with optimizations
- Apply overrides — Update domains, system config, and run SQL updates
- Clear cache — Run
cache:clear:all - Run post-sync commands — Execute configured console commands
- Cleanup local — Delete the local dump file (unless
--keep-dump)
The plugin uses a two-step dump process:
- Structure dump:
--no-data --routinesexports table structures, triggers, stored procedures, and functions - Data dump:
--no-create-info --skip-triggersexports data only, skipping ignored tables
Common flags:
--single-transaction— InnoDB consistent read without table locks (safe for production)--quick— Stream results without buffering entire tables-C— Compress data between client and server--hex-blob— Binary data as hex for portability--column-statistics=0— Disable statistics collection (auto-detected if supported)
Post-processing (both steps):
LANG=C LC_CTYPE=C LC_ALL=C— Consistent character encodingsedstripsDEFINERclauses for cross-server compatibility
The import pipeline applies several optimizations:
SET FOREIGN_KEY_CHECKS=0— Disables FK constraint checks during import to prevent deadlocks and speed up loadingSET UNIQUE_CHECKS=0— Skips unique index verification during bulk insertSET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"— Preserves explicit zero values in auto-increment columns- DEFINER clauses are stripped locally via
sedbefore piping tomysql, avoiding privilege errors when views or stored procedures reference specific users - Foreign key and unique checks are re-enabled at the end of the import
- If
sw-db-sync-config.jsonexists → use config file (sales channel domains, system config, SQL updates) - Otherwise → use environment variable domain mappings (
SW_DB_SYNC_DOMAIN_MAPPINGS) - Fallback → use
SW_DB_SYNC_LOCAL_DOMAINto set all sales channel domains
- In DDEV: Run
ddev auth sshto forward your SSH agent into the container - SSH Key: Set
SW_DB_SYNC_[ENV]_KEYto your private key path - SSH Agent: Ensure your key is loaded:
ssh-add ~/.ssh/your_key
Your SSH user needs:
- Read access to the remote
.envfile - Execute permissions for
mysqldump - Write permissions to the remote project directory (for temporary dump file)
Verify that SW_DB_SYNC_[ENV]_PROJECT_PATH points to the Shopware root directory containing the .env file.
The plugin reads remote environment files in this priority order:
.env.local.php— Cached PHP array (takes full precedence if exists).env.local— Local overrides (merged on top of.env).env— Base environment file
This matches Symfony's environment loading behavior.
This is handled automatically. Both the remote dump and local import pipeline strip DEFINER clauses. If you still encounter errors, check that your MySQL user has SUPER or PROXY privileges, or verify the dump file isn't corrupted.
- Shopware 6.6+ & 6.7+
- PHP 8.1+
- SSH access to remote servers
mysqldumpon the remote serverrsyncfor file transfergzip/gunzip(unless using--no-gzip)
Sidworks — https://www.sidworks.nl/