SR Dev Tools WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA
Sync WordPress to version-controlled JSON files for easy Git workflows.
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/studiorepublic/sr-dev-tools/archive/refs/heads/main.zipSync WordPress to version-controlled JSON files for easy Git workflows.
Export and import database
Export plugins to tar.gz archives
Overview
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
Key Features
Smart Content Export
- 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
Flexible Sync Options
- 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
Create module pages
- Module Page Creation: Easily create module pages directly from the plugin interface
Database Tools
- Dump Database: Create SQL dumps to your active theme's
sync/database/folder - List & Delete Dumps: View all available
.sqlfiles in the admin with size and timestamp, and delete individual dumps securely - One-click Import: Import the most recent dump; the Site URL and Home settings are restored automatically
Enterprise Ready
- 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
Requirements
- WordPress: 5.0 or higher
- PHP: 7.4 or higher
- File Permissions: Write access to sync directory
- WP-CLI: Optional, for command-line operations
🔧 Installation
Via WordPress Admin
- Download the plugin zip file
- Go to Plugins > Add New > Upload Plugin
- Upload and activate the plugin
- Navigate to SRDT Export in your admin menu
Manual Installation
- Upload the
db-version-controlfolder to/wp-content/plugins/ - Activate the plugin through the WordPress admin
- Configure your settings under SRDT Export
🎯 Quick Start
1. Configure Post Types
Navigate to SRDT 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
2. Set Sync Path
Choose where to store your JSON files:
wp-content/uploads/srdt-sync/ # Safe, backed up location
wp-content/plugins/db-version-control/sync/ # Plugin directory (default)
../site-content/ # Outside web root (recommended)
3. Run Your First Export
Via Admin Interface:
Click "Run Full Export" to generate JSON files for all content.
Via WP-CLI:
wp srdt export
4. Version Control Integration
Add your sync folder to Git:
cd your-sync-folder/
git init
git add .
git commit -m "Initial content export"
5. Manage Database Dumps
Go to the Database section under SRDT Export:
- Click "Dump database" to create a new SQL dump in your theme's
sync/database/folder - See a list of existing dumps with file size and modified time
- Use the Delete action next to a dump to remove it securely
- Click "Import database" to import the most recent dump (Site URL and Home are restored automatically)
WP-CLI Commands
Export All Content
wp srdt export
Exports all posts, pages, options, and menus to JSON files.
Batch Processing Options:
wp srdt export --batch-size=100 # Process 100 posts per batch
wp srdt export --batch-size=0 # Disable batching (process all at once)
Import All Content
wp srdt import
⚠️ Warning: This overwrites existing content. Always backup first!
Batch Processing Options:
wp srdt import --batch-size=25 # Process 25 files per batch
wp srdt import --batch-size=0 # Disable batching (process all at once)
Performance Considerations
Batch Size Recommendations:
- Small sites (< 1,000 posts):
--batch-size=100or--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=10with monitoring
Real-world Performance:
# Example output from a site with 395 posts across 6 post types
wp srdt 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
Example Automation Script
#!/bin/bash
# Daily content backup
wp srdt export
cd /path/to/sync/folder
git add -A
git commit -m "Automated content backup $(date)"
git push origin main
File Structure
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
└── ...
Workflow Examples
Development to Production
# On staging site
wp srdt export
git add sync/
git commit -m "Content updates for v2.1"
git push
# On production site
git pull
wp srdt import
Team Collaboration
# Content editor exports changes
wp srdt export
# Developer reviews in pull request
git diff sync/
# Changes merged and deployed
wp srdt import
Automated Deployment
# GitHub Actions example
- name: Deploy Content
run: |
wp srdt export
git add sync/
git commit -m "Auto-export: ${{ github.sha }}" || exit 0
git push
Developer Integration
Filters
Modify supported post types:
add_filter( 'srdt_supported_post_types', function( $post_types ) {
$post_types[] = 'my_custom_post_type';
return $post_types;
});
Exclude sensitive options:
add_filter( 'srdt_excluded_option_keys', function( $excluded ) {
$excluded[] = 'my_secret_api_key';
return $excluded;
});
Modify export data:
add_filter( 'srdt_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 );
Actions
Custom export operations:
add_action( 'srdt_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( 'srdt_skip_meta_keys', function( $skip_keys ) {
$skip_keys[] = '_temporary_data';
return $skip_keys;
});
⚠️ Important Considerations
Security
- 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
SRcapability can export/import
Performance
- 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
Data Integrity
- 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
Troubleshooting
Common Issues
Permission Denied Errors:
# Fix directory permissions
chmod 755 wp-content/uploads/srdt-sync/
chown www-data:www-data wp-content/uploads/srdt-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
Debug Mode
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
Contributing
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
Development Setup
git clone https://github.com/robertdevore/db-version-control.git
cd db-version-control
composer install
License
This project is licensed under the GPL v2+ License - see the LICENSE file for details.
👨💻 Author
Robert DeVore
- Website: robertdevore.com
- GitHub: @robertdevore
- X: @deviorobert
Releases
12 releases.
These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.