WP Local Sync
Facilitates secure local development environment synchronization
★ 0stars
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/patilswapnilv/wp-local-sync/archive/refs/heads/master.zipA WordPress plugin that facilitates secure local development environment synchronization with staging and production environments.
🚀 Features
- Environment Management (Local, Staging, Production)
- Secure SFTP/SSH File Transfer
- Database Backup and Restoration
- File System Backup with Rotation
- Environment-specific Configuration
- Secure Authentication using WordPress Application Passwords
- Progress Tracking for Long Operations
- Rate Limiting for Large Operations
- Detailed Error Logging and Monitoring
📋 Requirements
- PHP 7.4 or higher
- WordPress 5.6 or higher
- SSH/SFTP access to remote environments
- MySQL/MariaDB database
- PHP Extensions:
- ZIP (
php-zip) - OpenSSL (
php-openssl) - JSON (
php-json) - PDO (
php-pdo) - MySQLi (
php-mysqli)
- ZIP (
🔧 Quick Start Guide
-
Download and Install
cd wp-content/plugins/ git clone https://github.com/yourusername/wp-local-sync.git cd wp-local-sync -
Install Dependencies
composer install --no-dev -
Set Permissions
chmod 755 . find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \; -
Activate Plugin
- Go to WordPress Admin → Plugins
- Find "WP Local Sync"
- Click "Activate"
-
Initial Configuration
- Go to WordPress Admin → WP Local Sync
- Add your first environment
- Configure backup settings
⚙️ Configuration
Environment Setup
- Navigate to: WordPress Admin → WP Local Sync → Add Environment
- Required fields:
- Environment Name (e.g., "Local", "Staging")
- Host (e.g., "staging.example.com")
- SSH User
- SSH Key Path or Password
Example configuration:
[
'name' => 'Staging',
'host' => 'staging.example.com',
'ssh_user' => 'deploy',
'ssh_key_path' => '/home/user/.ssh/id_rsa',
'sftp_port' => 22,
'is_current' => false
]
Backup Settings
- Maximum backup size: 500MB (configurable)
- Backup retention: 30 days
- Maximum backups: 10 per environment
📝 API Usage
Authentication
All API requests require WordPress authentication. Use Application Passwords:
- Go to WordPress Admin → Users → Profile
- Scroll to Application Passwords
- Generate new password for "WP Local Sync"
API Endpoints
List Environments
GET /wp-json/wp-local-sync/v1/environments
Authorization: Basic base64(username:app_password)
Response:
[
{ "id": 1, "name": "Local", "host": "localhost", "ssh_user": "root", "ssh_key_path": null, "sftp_port": 22, "is_current": true }
]
Create Backup
POST /wp-json/wp-local-sync/v1/backups
Authorization: Basic base64(username:app_password)
Content-Type: application/json
Request body:
{
"environment_id": 1,
"backup_type": "full"
}
Response:
{
"success": true,
"backup_id": 123,
"filename": "backup-2024-03-22-123456.zip"
}
🔍 Debugging
-
Enable debug mode in wp-config.php:
define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WLS_DEBUG', true); -
Check logs:
- WordPress debug log:
/wp-content/debug.log - Plugin error log:
/wp-content/wls-logs/error.log
- WordPress debug log:
📦 Directory Structure
wp-local-sync/
├── assets/
│ ├── css/
│ │ └── admin.css
│ └── js/
│ └── admin.js
├── includes/
│ ├── class-environment-manager.php
│ ├── class-backup-manager.php
│ ├── class-error-handler.php
│ ├── class-rate-limiter.php
│ └── class-input-validator.php
├── templates/
│ └── admin-page.php
├── tests/
│ ├── TestCase.php
│ ├── EnvironmentManagerTest.php
│ └── BackupManagerTest.php
├── vendor/
├── composer.json
├── install.sh
├── README.md
└── wp-local-sync.php
🔄 Version History
[0.1.0] - 2024-03-22
- Initial beta release
- Basic environment management
- Backup functionality
- SFTP/SSH transfer
- Rate limiting
- Error logging
🤝 Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
Development Setup
- Clone repository
- Install all dependencies:
composer install - Run tests:
composer test
📞 Support
- Check Documentation
- Search Issues
- Create new issue with:
- WordPress version
- PHP version
- Error logs
- Steps to reproduce
📝 License
This project is licensed under the GPL v2 or later - see the LICENSE file for details
🙏 Acknowledgments
- WordPress Plugin Development Team
- Contributors & Testers
- Open Source Community