feat: remote site sync — deploy full installation to remote server via FTP/SFTP + MySQL #194

Open
opened 2026-06-30 18:03:02 +00:00 by jmiller · 1 comment
Owner

Summary

Add the ability to deploy a full Joomla installation to a remote server, keeping a staging/production pair (or any two sites) in sync. This goes beyond backup+restore — it's a one-click push of files and database to a pre-configured remote target with its own independent configuration.php.

Use Case

  • Push a local/staging site to a production server (or vice versa)
  • Keep a demo site synchronized with a development instance
  • Deploy client sites from a central build environment
  • Migrate between hosting providers with different credentials

Requirements

1. Target Configuration in Backup Profile

Each backup profile should support one or more sync targets, each defining:

  • Connection: FTP or SFTP credentials (reuse existing remote destinations from #__mokosuitebackup_remotes)
  • Remote document root: where Joomla lives on the target server (e.g. /home/user/public_html)
  • Target configuration.php overrides: a set of key-value pairs that replace the source site's config values on the target. At minimum:
    • sitename — different site name
    • host, db, user, password, dbprefix — target database credentials
    • tmp_path, log_path — target filesystem paths
    • live_site — target URL
    • secret — auto-generate a unique secret per target
    • smtphost, smtpuser, smtppass — target mail config
    • Any other JConfig property the user wants to override

2. Sync Process

  1. Run a full backup (database + files) as usual
  2. Upload files to the remote document root via FTP/SFTP (full push or delta/changed-files-only if feasible)
  3. Import database to the target MySQL server (connect directly via PDO if the DB is remotely accessible, or upload database.sql and trigger an import script)
  4. Write configuration.php on the target using the source config as a base, with the target overrides applied (same logic as MokoRestore's actionConfig)
  5. Post-sync tasks (optional): clear cache, clear sessions, regenerate secret, etc.

3. Database Deployment Options

Since direct MySQL access to the remote server may not be available, support multiple strategies:

  • Direct MySQL connection — connect to the target DB host from the source server (simplest when the DB allows remote connections)
  • Upload + remote script — upload a temporary PHP import script alongside database.sql, trigger it via HTTP, then delete it (similar to how MokoRestore works)
  • SSH tunnel — if SFTP is configured, tunnel the MySQL connection through SSH

4. UI

  • New section in the profile editor: Sync Targets
  • Each target has a name, connection (from existing remotes), remote path, and a config overrides editor (key-value pairs)
  • "Sync Now" button on the dashboard or profile view
  • Progress/log output similar to the existing backup flow

Future Considerations

  • Delta sync (only upload changed files) for faster subsequent pushes
  • Scheduled sync via task scheduler or web cron
  • Bidirectional sync (pull from remote)
  • Dry-run mode that shows what would change without deploying
  • Pre/post-sync hooks (run commands on the remote server via SSH)
## Summary Add the ability to deploy a full Joomla installation to a remote server, keeping a staging/production pair (or any two sites) in sync. This goes beyond backup+restore — it's a one-click push of files and database to a pre-configured remote target with its own independent `configuration.php`. ## Use Case - Push a local/staging site to a production server (or vice versa) - Keep a demo site synchronized with a development instance - Deploy client sites from a central build environment - Migrate between hosting providers with different credentials ## Requirements ### 1. Target Configuration in Backup Profile Each backup profile should support one or more **sync targets**, each defining: - **Connection**: FTP or SFTP credentials (reuse existing remote destinations from `#__mokosuitebackup_remotes`) - **Remote document root**: where Joomla lives on the target server (e.g. `/home/user/public_html`) - **Target `configuration.php` overrides**: a set of key-value pairs that replace the source site's config values on the target. At minimum: - `sitename` — different site name - `host`, `db`, `user`, `password`, `dbprefix` — target database credentials - `tmp_path`, `log_path` — target filesystem paths - `live_site` — target URL - `secret` — auto-generate a unique secret per target - `smtphost`, `smtpuser`, `smtppass` — target mail config - Any other `JConfig` property the user wants to override ### 2. Sync Process 1. **Run a full backup** (database + files) as usual 2. **Upload files** to the remote document root via FTP/SFTP (full push or delta/changed-files-only if feasible) 3. **Import database** to the target MySQL server (connect directly via PDO if the DB is remotely accessible, or upload `database.sql` and trigger an import script) 4. **Write `configuration.php`** on the target using the source config as a base, with the target overrides applied (same logic as MokoRestore's `actionConfig`) 5. **Post-sync tasks** (optional): clear cache, clear sessions, regenerate secret, etc. ### 3. Database Deployment Options Since direct MySQL access to the remote server may not be available, support multiple strategies: - **Direct MySQL connection** — connect to the target DB host from the source server (simplest when the DB allows remote connections) - **Upload + remote script** — upload a temporary PHP import script alongside `database.sql`, trigger it via HTTP, then delete it (similar to how MokoRestore works) - **SSH tunnel** — if SFTP is configured, tunnel the MySQL connection through SSH ### 4. UI - New section in the profile editor: **Sync Targets** - Each target has a name, connection (from existing remotes), remote path, and a config overrides editor (key-value pairs) - "Sync Now" button on the dashboard or profile view - Progress/log output similar to the existing backup flow ## Future Considerations - Delta sync (only upload changed files) for faster subsequent pushes - Scheduled sync via task scheduler or web cron - Bidirectional sync (pull from remote) - Dry-run mode that shows what would change without deploying - Pre/post-sync hooks (run commands on the remote server via SSH)
Author
Owner

Branch created: feature/194-feat-remote-site-sync-deploy-full-instal

git fetch origin
git checkout feature/194-feat-remote-site-sync-deploy-full-instal
Branch created: [`feature/194-feat-remote-site-sync-deploy-full-instal`](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteBackup/src/branch/feature/194-feat-remote-site-sync-deploy-full-instal) ```bash git fetch origin git checkout feature/194-feat-remote-site-sync-deploy-full-instal ```
Sign in to join this conversation.