Files
Jonathan Miller 37d325f1ed
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Has been cancelled
chore: rename mokobackup to mokojoombackup throughout
Full rename of all extension elements, namespaces, language keys,
database tables, file names, and directory names:

- pkg_mokobackup → pkg_mokojoombackup
- com_mokobackup → com_mokojoombackup
- plg_*_mokobackup → plg_*_mokojoombackup
- MokoBackup namespace → MokoJoomBackup
- #__mokobackup_ tables → #__mokojoombackup_
- COM_MOKOBACKUP_ keys → COM_MOKOJOOMBACKUP_

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 14:54:04 -05:00

69 lines
1.7 KiB
PHP

<?php
/**
* @package MokoJoomBackup
* @subpackage com_mokojoombackup
* @author Moko Consulting <hello@mokoconsulting.tech>
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE
*
* CLI backup script for cron/scheduled use.
*
* Usage:
* php cli/mokojoombackup.php --profile=1 --description="Scheduled backup"
*
* Must be run from the Joomla root directory.
*/
// Define Joomla constants
const _JEXEC = 1;
// Bootstrap Joomla
if (file_exists(dirname(__DIR__, 4) . '/includes/defines.php')) {
require_once dirname(__DIR__, 4) . '/includes/defines.php';
}
if (!defined('JPATH_BASE')) {
define('JPATH_BASE', dirname(__DIR__, 4));
}
require_once JPATH_BASE . '/includes/framework.php';
use Joomla\CMS\Factory;
use Joomla\Component\MokoJoomBackup\Administrator\Engine\BackupEngine;
// Parse CLI arguments
$profileId = 1;
$description = '';
foreach ($argv as $arg) {
if (str_starts_with($arg, '--profile=')) {
$profileId = (int) substr($arg, 10);
} elseif (str_starts_with($arg, '--description=')) {
$description = substr($arg, 14);
}
}
if (empty($description)) {
$description = 'CLI backup ' . date('Y-m-d H:i:s');
}
// Boot the application
$app = Factory::getApplication('administrator');
echo "MokoJoomBackup CLI\n";
echo "Profile: {$profileId}\n";
echo "Description: {$description}\n";
echo "Starting backup...\n\n";
$engine = new BackupEngine();
$result = $engine->run($profileId, $description, 'cli');
if ($result['success']) {
echo "SUCCESS: " . $result['message'] . "\n";
exit(0);
} else {
echo "FAILED: " . $result['message'] . "\n";
exit(1);
}