add backup settings and update cron fork

Signed-off-by: Maurice Preuß (envoyr) <envoyr@froxlor.org>
This commit is contained in:
Maurice Preuß (envoyr)
2023-06-06 17:30:12 +02:00
parent 2ec039372d
commit 94051dc9eb
10 changed files with 259 additions and 127 deletions

View File

@@ -700,6 +700,16 @@ opcache.validate_timestamps'),
('system', 'traffictool', 'goaccess'),
('system', 'req_limit_per_interval', 60),
('system', 'req_limit_interval', 60),
('backup', 'enabled', 0),
('backup', 'type', 'Local'),
('backup', 'region', ''),
('backup', 'bucket', ''),
('backup', 'destination_path', '/srv/backups/'),
('backup', 'hostname', ''),
('backup', 'username', ''),
('backup', 'password', ''),
('backup', 'pgp_public_key', ''),
('backup', 'retention', '3'),
('api', 'enabled', '0'),
('api', 'customer_default', '1'),
('2fa', 'enabled', '1'),
@@ -913,7 +923,8 @@ INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `cronclass`, `interval`,
(3, 'froxlor/reports', 'usage_report', '\\Froxlor\\Cron\\Traffic\\ReportsCron', '1 DAY', '1', 'cron_usage_report'),
(4, 'froxlor/core', 'mailboxsize', '\\Froxlor\\Cron\\System\\MailboxsizeCron', '6 HOUR', '1', 'cron_mailboxsize'),
(5, 'froxlor/letsencrypt', 'letsencrypt', '\\Froxlor\\Cron\\Http\\LetsEncrypt\\AcmeSh', '5 MINUTE', '0', 'cron_letsencrypt'),
(6, 'froxlor/backup', 'backup', '\\Froxlor\\Cron\\System\\BackupCron', '1 DAY', '0', 'cron_backup');
(6, 'froxlor/export', 'export', '\\Froxlor\\Cron\\System\\ExportCron', '1 DAY', '0', 'cron_export');
(7, 'froxlor/backup', 'backup', '\\Froxlor\\Cron\\Backup\\BackupCron', '1 DAY', '0', 'cron_backup');
DROP TABLE IF EXISTS `ftp_quotalimits`;

View File

@@ -524,5 +524,52 @@ if (Froxlor::isDatabaseVersion('202304260')) {
Update::lastStepStatus(1, 'Customized setting, not changing');
}
Update::showUpdateStep("Creating new tables and fields for backups");
Database::query("DROP TABLE IF EXISTS `panel_backups`;");
$sql = "CREATE TABLE `panel_backups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`adminid` int(11) NOT NULL,
`customerid` int(11) NOT NULL,
`loginname` varchar(255) NOT NULL,
`size` bigint(20) NOT NULL,
`created_at` int(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
Database::query($sql);
Update::lastStepStatus(0);
Update::showUpdateStep("Adding new backup settings");
Settings::AddNew('backup.enabled', 0);
Settings::AddNew('backup.type', 'Local');
Settings::AddNew('backup.region', '');
Settings::AddNew('backup.bucket', '');
Settings::AddNew('backup.destination_path', '/srv/backups/');
Settings::AddNew('backup.hostname', '');
Settings::AddNew('backup.username', '');
Settings::AddNew('backup.password', '');
Settings::AddNew('backup.pgp_public_key', '');
Settings::AddNew('backup.retention', 3);
Update::lastStepStatus(0);
Update::showUpdateStep("Adjusting cronjobs");
Database::query("
UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET
`module`= 'froxlor/export',
`cronfile` = 'export',
`cronclass` = '\\Froxlor\\Cron\\System\\ExportCron',
`desc_lng_key` = 'cron_export'
WHERE `module` = 'froxlor/backup'
");
Database::query("
INSERT INTO `" . TABLE_PANEL_CRONRUNS . "` SET
`module`= 'froxlor/backup',
`cronfile` = 'backup',
`cronclass` = '\\Froxlor\\Cron\\Backup\\BackupCron',
`interval` = '1 DAY',
`isactive` = '0',
`desc_lng_key` = 'cron_backup'
");
Update::lastStepStatus(0);
Froxlor::updateToDbVersion('202305240');
}