Syncing Extensions, Plugins, and Modules
By the end of this module, you will be able to synchronize modular application components (plugins, themes, scripts) while avoiding the common traps of syncing bloated dependency directories.
Modular Application Structure
Most modern systems rely on a modular architecture where the core logic is extended by plugins, themes, or modules. These components are often the most frequently changed parts of an application.
/app/
├── modules/ ← Custom business logic modules (sync these)
├── plugins/ ← Third-party extensions
├── themes/ ← UI and presentation layers
├── vendor/ ← PERSISTENT dependencies (handle with care)
└── scripts/ ← Deployment and maintenance scripts
Syncing Custom Components
Deploying a Specific Module or Theme
When you've only modified one part of the system, it's faster and safer to sync only that directory.
rsync -avz --exclude='.git/' --exclude='node_modules/' \
/local/dev/themes/my-custom-ui/ \
user@production:/var/www/app/themes/my-custom-ui/
Syncing All Plugins/Extensions
Use this when you need to mirror the entire extension ecosystem from staging to production.
rsync -avz --delete \
/staging/app/plugins/ \
user@production:/var/www/app/plugins/
The --delete flag will remove any plugins from the destination that aren't present on the source. Always use --dry-run (-n) first to verify what will be removed.
Managing Dependencies (Vendor and node_modules)
Dependency directories are unique because they are usually managed by tools (npm, composer, pip) rather than manually edited.
The Problem with Syncing Dependencies
- Size: These directories can contain tens of thousands of small files, making rsync indexing very slow.
- Platform Specifics: Compiled binaries (like
bcryptorsharpin Node.js) may not work if the source and destination OS/architecture differ. - Environment Flux: Syncing these can lead to version mismatches between the code and its dependencies.
The Correct Strategy
Avoid syncing these directories. Instead, sync the lockfiles and rebuild on the destination.
| Action | Command |
|---|---|
| Syncing | rsync -av package.json package-lock.json user@remote:/app/ |
| Rebuilding | ssh user@remote "cd /app && npm ci --production" |
Deployment Exclusions
When syncing code components, always exclude files that add bulk or expose environment metadata.
rsync -avz \
--exclude='.git/' \
--exclude='.github/' \
--exclude='node_modules/' \
--exclude='src/tests/' \
--exclude='*.log' \
--exclude='.DS_Store' \
/local/app/modules/ user@remote:/var/www/app/modules/
| Exclusion Pattern | Reason |
|---|---|
.git/ | Version history is for development; adds massive bulk to transfers. |
node_modules/ | Rebuild on the server to ensure platform compatibility. |
*.log | Logs are unique to the local environment and clutter production. |
tests/ | Unit tests aren't usually needed for execution in production. |
Real-World Comparison
| Framework | Extension Directory | Sync Best Practice |
|---|---|---|
| WordPress | wp-content/plugins/ | Sync custom plugins; exclude cache. |
| Laravel | packages/ | Sync local packages; use Composer for vendor/. |
| Drupal | modules/custom/ | Always sync custom/ separately from contrib/. |
| Express.js | routes/ or controllers/ | Sync all source; rebuild node_modules/. |
| Magento | app/code/ | Sync custom extensions; ignore generated/ and pub/static/. |
Common Pitfalls
| Pitfall | Consequence | Prevention |
|---|---|---|
Syncing .git | Dramatically slows down sync and exposes repo history on the server. | Add --exclude='.git/'. |
Overwriting with --delete | Accidental deletion of production-only extensions. | Always verify with --dry-run first. |
| Mixing build artifacts | Deploying unminified or dev-only assets. | Sync from a dist/ or build/ folder if available. |
| Permission Drift | Modules fail to load due to wrong ownership. | Run chown after sync to match the web user. |
What's Next
- User Media and Uploads — Strategies for syncing the largest part of any application: user data.
- Excludes and Includes — Deep dive into advanced rsync filtering rules.
- CI/CD Automation — Integrating these patterns into automated deployment pipelines.