Sync WordPress to version-controlled JSON files for easy Git workflows.
DB Version Control bridges the gap between WordPress content management and modern development workflows.
Instead of wrestling with database dumps or complex migration tools, this plugin exports your WordPress content to clean, readable JSON files that work seamlessly with Git and other version control systems.
Perfect for:
- Development teams managing content across environments
- DevOps workflows requiring automated content deployment
- Agencies syncing content between staging and production
- Content editors who want change tracking and rollback capabilities
- Selective Post Types: Choose which post types to include in exports
- Automatic Triggers: Content exports automatically on saves, updates, and changes
- Organized Structure: Each post type gets its own folder for clean organization
- Complete Data: Includes post content, meta fields, options, and navigation menus
- Custom Sync Paths: Set your own export directory (supports relative and absolute paths)
- WP-CLI Integration: Command-line tools for automation and CI/CD pipelines
- Manual Exports: On-demand exports through the admin interface
- Selective Imports: Import specific content types as needed
- Security First: CSRF protection, capability checks, and input sanitization
- Error Handling: Comprehensive logging and graceful failure handling
- Performance Optimized: Efficient file operations with minimal overhead
- Extensible: 20+ filters and actions for custom integrations
- WordPress: 5.0 or higher
- PHP: 7.4 or higher
- File Permissions: Write access to sync directory
- WP-CLI: Optional, for command-line operations
- Download the plugin zip file
- Go to Plugins > Add New > Upload Plugin
- Upload and activate the plugin
- Navigate to DBVC Export in your admin menu
- Upload the
db-version-control
folder to/wp-content/plugins/
- Activate the plugin through the WordPress admin
- Configure your settings under DBVC Export
Navigate to DBVC Export and select which post types you want to sync:
- Posts and Pages (enabled by default)
- Custom post types (WooCommerce products, events, etc.)
- Choose based on your content strategy
Choose where to store your JSON files:
wp-content/uploads/dbvc-sync/ # Safe, backed up location
wp-content/plugins/db-version-control/sync/ # Plugin directory (default)
../site-content/ # Outside web root (recommended)
Via Admin Interface:
Click "Run Full Export" to generate JSON files for all content.
Via WP-CLI:
wp dbvc export
Add your sync folder to Git:
cd your-sync-folder/
git init
git add .
git commit -m "Initial content export"
wp dbvc export
Exports all posts, pages, options, and menus to JSON files.
Batch Processing Options:
wp dbvc export --batch-size=100 # Process 100 posts per batch
wp dbvc export --batch-size=0 # Disable batching (process all at once)
wp dbvc import
Batch Processing Options:
wp dbvc import --batch-size=25 # Process 25 files per batch
wp dbvc import --batch-size=0 # Disable batching (process all at once)
Batch Size Recommendations:
- Small sites (< 1,000 posts):
--batch-size=100
or--batch-size=0
- Medium sites (1,000-10,000 posts):
--batch-size=50
(default) - Large sites (> 10,000 posts):
--batch-size=25
- Very large sites:
--batch-size=10
with monitoring
Real-world Performance:
# Example output from a site with 395 posts across 6 post types
wp dbvc export --batch-size=50
Starting batch export with batch size: 50
Processed batch: 50 posts | Total: 50/398 | Remaining: 348
Processed batch: 50 posts | Total: 100/398 | Remaining: 298
...
Processed batch: 45 posts | Total: 395/398 | Remaining: 3
Success: Batch export completed! Processed 395 posts across post types: post, page, docupress, boostbox_popups, product, projects
#!/bin/bash
# Daily content backup
wp dbvc export
cd /path/to/sync/folder
git add -A
git commit -m "Automated content backup $(date)"
git push origin main
sync-folder/
├── options.json # WordPress options/settings
├── menus.json # Navigation menus
├── post/ # Blog posts
│ ├── post-1.json
│ ├── post-2.json
│ └── ...
├── page/ # Static pages
│ ├── page-10.json
│ ├── page-15.json
│ └── ...
└── product/ # WooCommerce products (if enabled)
├── product-100.json
└── ...
# On staging site
wp dbvc export
git add sync/
git commit -m "Content updates for v2.1"
git push
# On production site
git pull
wp dbvc import
# Content editor exports changes
wp dbvc export
# Developer reviews in pull request
git diff sync/
# Changes merged and deployed
wp dbvc import
# GitHub Actions example
- name: Deploy Content
run: |
wp dbvc export
git add sync/
git commit -m "Auto-export: ${{ github.sha }}" || exit 0
git push
Modify supported post types:
add_filter( 'dbvc_supported_post_types', function( $post_types ) {
$post_types[] = 'my_custom_post_type';
return $post_types;
});
Exclude sensitive options:
add_filter( 'dbvc_excluded_option_keys', function( $excluded ) {
$excluded[] = 'my_secret_api_key';
return $excluded;
});
Modify export data:
add_filter( 'dbvc_export_post_data', function( $data, $post_id, $post ) {
// Add custom fields or modify data
$data['custom_field'] = get_field( 'my_field', $post_id );
return $data;
}, 10, 3 );
Custom export operations:
add_action( 'dbvc_after_export_post', function( $post_id, $post, $file_path ) {
// Custom logic after post export
do_something_with_exported_post( $post_id );
});
Skip certain meta keys:
add_filter( 'dbvc_skip_meta_keys', function( $skip_keys ) {
$skip_keys[] = '_temporary_data';
return $skip_keys;
});
- File Permissions: Ensure proper write permissions for sync directory
- Sensitive Data: Some options are automatically excluded (API keys, salts, etc.)
- Access Control: Only users with
manage_options
capability can export/import
- Large Sites: Batch processing automatically handles large datasets efficiently
- Memory Usage: Batching prevents memory exhaustion on large imports/exports
- Server Load: Built-in delays (0.1s export, 0.25s import) prevent overwhelming server resources
- Progress Tracking: Real-time feedback shows processed/remaining counts during batch operations
- Scalable: Successfully tested with 395+ posts across 6 different post types
- Always Backup: Import operations overwrite existing content
- Test First: Use staging environments for testing import/export workflows
- Validate JSON: Malformed JSON files will be skipped during import
Permission Denied Errors:
# Fix directory permissions
chmod 755 wp-content/uploads/dbvc-sync/
chown www-data:www-data wp-content/uploads/dbvc-sync/
WP-CLI Command Not Found:
# Verify WP-CLI installation
wp --info
# Check plugin activation
wp plugin list | grep db-version-control
Empty Export Files:
- Check if post types are selected in settings
- Verify posts exist and are published
- Check error logs for file write issues
Enable WordPress debug logging to troubleshoot issues:
// wp-config.php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
// Check logs at: wp-content/debug.log
Contributions are always welcome! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
git clone https://github.com/robertdevore/db-version-control.git
cd db-version-control
composer install
This project is licensed under the GPL v2+ License - see the LICENSE file for details.
Robert DeVore
- Website: robertdevore.com
- GitHub: @robertdevore
- X: @deviorobert