1
Architecture
Jonathan Miller edited this page 2026-06-29 16:46:02 +00:00

Architecture

Package Structure

MokoSuiteBackup is a Joomla 6 package (pkg_mokosuitebackup) containing 9 sub-extensions plus the bundled MokoSuiteClient package.

source/
├── pkg_mokosuitebackup.xml          # Package manifest
├── script.php                        # Install/update script
├── language/                         # Package-level language files
└── packages/
    ├── com_mokosuitebackup/          # Core component
    ├── plg_system_mokosuitebackup/   # System plugin (cleanup, webcron)
    ├── plg_task_mokosuitebackup/     # Task plugin (scheduled backups)
    ├── plg_quickicon_mokosuitebackup/# Quick icon plugin (dashboard widget)
    ├── plg_webservices_mokosuitebackup/# Web services plugin (REST API routes)
    ├── plg_console_mokosuitebackup/  # Console plugin (CLI commands)
    ├── plg_content_mokosuitebackup/  # Content plugin (pre-update/uninstall backup)
    ├── plg_actionlog_mokosuitebackup/# Action log plugin (audit trail)
    ├── mod_mokosuitebackup_cpanel/   # Admin CPanel dashboard module
    └── MokoSuiteClient/              # Bundled MokoSuiteClient package

Component MVC

The core component (com_mokosuitebackup) follows the Joomla 6 MVC architecture with namespace Joomla\Component\MokoSuiteBackup\Administrator.

Controllers

Controller Purpose
DisplayController Default display controller
BackupController Single backup record actions (download, delete, verify)
BackupsController Backup list operations
ProfileController Single profile edit/save
ProfilesController Profile list operations
SnapshotsController Snapshot list, create, restore, delete
AjaxController AJAX endpoints (remote destinations, progress polling)

Models

Model Type Purpose
DashboardModel AdminModel Dashboard statistics, health checks, trend data
BackupModel AdminModel Single backup record CRUD
BackupsModel ListModel Backup records list with filters
ProfileModel AdminModel Single profile CRUD
ProfilesModel ListModel Profiles list with filters
SnapshotModel AdminModel Single snapshot operations
SnapshotsModel ListModel Snapshots list
RemoteModel AdminModel Single remote destination CRUD
RemotesModel ListModel Remote destinations per profile

Views

View Purpose
Dashboard/HtmlView Dashboard with health checks, stats, trend chart
Backup/HtmlView Individual backup record detail
Backups/HtmlView Backup records list
Profile/HtmlView Profile edit form
Profiles/HtmlView Profiles list
Snapshots/HtmlView Snapshots list with browse/restore modals

Tables

Table Class DB Table
BackupTable #__mokosuitebackup_records
ProfileTable #__mokosuitebackup_profiles
RemoteTable #__mokosuitebackup_remotes

Engine Layer

The backup/restore logic lives in src/Engine/, separated from the MVC layer.

Backup Engines

Class Purpose
BackupEngine Core single-request backup orchestrator
SteppedBackupEngine Multi-step backup for large sites (AJAX-driven)
SteppedSession Session state manager for stepped operations
PreflightCheck Validates directory, disk space, extensions, credentials

Restore Engines

Class Purpose
RestoreEngine Core restore logic (database + files)
SteppedRestoreEngine Multi-step restore for large archives
MokoRestore Standalone restore wizard (9-step, no Joomla required)
FileRestorer Extract and place files from archive
DatabaseImporter Import SQL dump back into database

Snapshot Engines

Class Purpose
SnapshotEngine Create JSON snapshots of articles, categories, modules
SnapshotRestoreEngine Restore content from JSON snapshots (Replace/Merge/Selective)

Archivers (implement ArchiverInterface)

Class Format
ZipArchiver ZIP with optional AES-256 encryption
TarGzArchiver tar.gz via PHP PharData
SevenZipArchiver 7z via system 7za/7z binary with native encryption

Remote Uploaders (implement RemoteUploaderInterface)

Class Service
FtpUploader FTP/FTPS
SftpUploader SFTP with password or SSH key auth
S3Uploader Amazon S3 and S3-compatible (streaming upload)
GoogleDriveUploader Google Drive via OAuth2

Supporting Classes

Class Purpose
DatabaseDumper Streaming database dump to temp file (prevents OOM)
DifferentialScanner File manifest comparison for differential backups
FileScanner Recursive file discovery with exclusion filters
NotificationSender Email and ntfy push notifications
PlaceholderResolver Resolve [HOST], [DATE], etc. in paths and filenames
AkeebaImporter Import profiles and history from Akeeba Backup
JpaUnarchiver Extract JPA format archives (Akeeba format)

Custom Fields

Field Class Purpose
DatabaseTablesField Multi-select list of database tables
DirectoryFilterField Directory path exclusion editor
ExcludeListField Generic newline-separated exclusion list
FolderPickerField Directory browser with validation
IpWhitelistField IP address list with auto-detect
PlaceholderTextField Text field with clickable placeholder pills
SftpPathField SFTP remote directory browser
SshKeyField SSH key file upload (stored base64, never exposed)
WebcronSecretField Secret key with CSPRNG generator + strength meter

Plugin Hooks

System Plugin (plg_system_mokosuitebackup)

  • onAfterInitialise: Handles webcron requests (secret + IP validation)
  • Periodic cleanup of expired backups and orphaned records

Task Plugin (plg_task_mokosuitebackup)

  • Task type run_profile: Run a backup profile on schedule
  • Task type run_snapshot: Create a content snapshot on schedule

Content Plugin (plg_content_mokosuitebackup)

  • onExtensionBeforeUpdate: Auto-backup before extension update
  • onExtensionBeforeUninstall: Auto-backup before extension uninstall

Action Log Plugin (plg_actionlog_mokosuitebackup)

  • Logs backup, restore, snapshot, profile CRUD, and purge actions to Joomla Action Logs

Quick Icon Plugin (plg_quickicon_mokosuitebackup)

  • onGetIcons: Provides backup status icon for admin dashboard

Web Services Plugin (plg_webservices_mokosuitebackup)

  • Registers JSON:API routes for backups, profiles, and snapshots

Console Plugin (plg_console_mokosuitebackup)

  • mokosuitebackup:run — Run a backup profile
  • mokosuitebackup:restore — Restore from a backup (--files-only, --db-only, --password)
  • mokosuitebackup:list — List backup records
  • mokosuitebackup:profiles — List profiles
  • mokosuitebackup:cleanup — Run retention cleanup
  • mokosuitebackup:snapshot — Create, restore, list, delete snapshots

API Endpoints

The REST API is registered via plg_webservices_mokosuitebackup and accessible at /api/index.php/v1/mokosuitebackup/.

Method Endpoint Action
GET /backups List backup records
POST /backups Start a new backup
GET /backups/:id Get backup record details
DELETE /backups/:id Delete a backup record
GET /snapshots List snapshots
POST /snapshots Create a snapshot
POST /snapshots/:id/restore Restore a snapshot
DELETE /snapshots/:id Delete a snapshot