more work on backup-storages
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -918,7 +918,7 @@ INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `cronclass`, `interval`,
|
|||||||
(3, 'froxlor/reports', 'usage_report', '\\Froxlor\\Cron\\Traffic\\ReportsCron', '1 DAY', '1', 'cron_usage_report'),
|
(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'),
|
(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'),
|
(5, 'froxlor/letsencrypt', 'letsencrypt', '\\Froxlor\\Cron\\Http\\LetsEncrypt\\AcmeSh', '5 MINUTE', '0', 'cron_letsencrypt'),
|
||||||
(6, 'froxlor/export', 'export', '\\Froxlor\\Cron\\System\\ExportCron', '1 DAY', '0', 'cron_export'),
|
(6, 'froxlor/export', 'export', '\\Froxlor\\Cron\\System\\ExportCron', '1 HOUR', '0', 'cron_export'),
|
||||||
(7, 'froxlor/backup', 'backup', '\\Froxlor\\Cron\\Backup\\BackupCron', '1 DAY', '0', 'cron_backup');
|
(7, 'froxlor/backup', 'backup', '\\Froxlor\\Cron\\Backup\\BackupCron', '1 DAY', '0', 'cron_backup');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@
|
|||||||
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Froxlor\Froxlor;
|
|
||||||
use Froxlor\FileDir;
|
|
||||||
use Froxlor\Database\Database;
|
use Froxlor\Database\Database;
|
||||||
use Froxlor\Settings;
|
use Froxlor\FileDir;
|
||||||
|
use Froxlor\Froxlor;
|
||||||
use Froxlor\Install\Update;
|
use Froxlor\Install\Update;
|
||||||
|
use Froxlor\Settings;
|
||||||
use Froxlor\System\Cronjob;
|
use Froxlor\System\Cronjob;
|
||||||
use Froxlor\System\IPTools;
|
use Froxlor\System\IPTools;
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ if (Froxlor::isDatabaseVersion('202304260')) {
|
|||||||
`module`= 'froxlor/export',
|
`module`= 'froxlor/export',
|
||||||
`cronfile` = 'export',
|
`cronfile` = 'export',
|
||||||
`cronclass` = '\\Froxlor\\Cron\\System\\ExportCron',
|
`cronclass` = '\\Froxlor\\Cron\\System\\ExportCron',
|
||||||
|
`interval` = '1 HOUR',
|
||||||
`desc_lng_key` = 'cron_export'
|
`desc_lng_key` = 'cron_export'
|
||||||
WHERE `module` = 'froxlor/backup'
|
WHERE `module` = 'froxlor/backup'
|
||||||
");
|
");
|
||||||
|
|||||||
@@ -36,7 +36,19 @@ $preconfig = [
|
|||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
if (Update::versionInUpdate($current_version, '2.1.0-dev1')) {
|
if (Update::versionInUpdate($current_version, '2.1.0-dev1')) {
|
||||||
|
// Backup
|
||||||
|
$description = 'Froxlor now comes with a backup capability (More info see [DOCS LINK].';
|
||||||
|
$question = '<strong>Would you like to enable the backup-feature (default: yes)</strong>';
|
||||||
|
$return['panel_settings_mode'] = [
|
||||||
|
'type' => 'select',
|
||||||
|
'select_var' => [
|
||||||
|
0 => 'No',
|
||||||
|
1 => 'Yes'
|
||||||
|
],
|
||||||
|
'selected' => 1,
|
||||||
|
'label' => $question,
|
||||||
|
'prior_infotext' => $description
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$preconfig['fields'] = $return;
|
$preconfig['fields'] = $return;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ use Froxlor\Api\ResourceEntity;
|
|||||||
use Froxlor\Database\Database;
|
use Froxlor\Database\Database;
|
||||||
use Froxlor\FileDir;
|
use Froxlor\FileDir;
|
||||||
use Froxlor\FroxlorLogger;
|
use Froxlor\FroxlorLogger;
|
||||||
|
use Froxlor\Settings;
|
||||||
use Froxlor\UI\Response;
|
use Froxlor\UI\Response;
|
||||||
use Froxlor\Validate\Validate;
|
use Froxlor\Validate\Validate;
|
||||||
use PDO;
|
use PDO;
|
||||||
@@ -40,6 +41,14 @@ use PDO;
|
|||||||
*/
|
*/
|
||||||
class BackupStorages extends ApiCommand implements ResourceEntity
|
class BackupStorages extends ApiCommand implements ResourceEntity
|
||||||
{
|
{
|
||||||
|
const SUPPORTED_TYPES = [
|
||||||
|
'local',
|
||||||
|
'ftp',
|
||||||
|
'sftp',
|
||||||
|
'rsync',
|
||||||
|
's3',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lists all backup storages entries
|
* lists all backup storages entries
|
||||||
*
|
*
|
||||||
@@ -61,7 +70,7 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
public function listing()
|
public function listing()
|
||||||
{
|
{
|
||||||
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
|
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
|
||||||
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] list backups");
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] list backup storages");
|
||||||
$query_fields = [];
|
$query_fields = [];
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT * FROM `" . TABLE_PANEL_BACKUP_STORAGES . "`
|
SELECT * FROM `" . TABLE_PANEL_BACKUP_STORAGES . "`
|
||||||
@@ -103,28 +112,28 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a backup storage by given id
|
* create a backup storage
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* required, backup storage type
|
* required, backup storage type
|
||||||
* @param string $destination_path
|
* @param string $destination_path
|
||||||
* required, destination path for backup storage
|
* required, destination path for backup storage
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* description for backup storage
|
* required, description for backup storage
|
||||||
* @param string $region
|
* @param string $region
|
||||||
* region for backup storage (used for S3)
|
* optional, required if type=s3. Region for backup storage (used for S3)
|
||||||
* @param string $bucket
|
* @param string $bucket
|
||||||
* bucket for backup storage (used for S3)
|
* optional, required if type=s3. Bucket for backup storage (used for S3)
|
||||||
* @param string $hostname
|
* @param string $hostname
|
||||||
* hostname for backup storage
|
* optional, required if type != local. Hostname for backup storage
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* username for backup storage (also used as access key for S3)
|
* optional, required if type != local. Username for backup storage (also used as access key for S3)
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* password for backup storage (also used as secret key for S3)
|
* optional, required if type != local. Password for backup storage (also used as secret key for S3)
|
||||||
* @param string $pgp_public_key
|
* @param string $pgp_public_key
|
||||||
* pgp public key for backup storage
|
* optional, pgp public key for backup storage
|
||||||
* @param string $retention
|
* @param string $retention
|
||||||
* retention for backup storage
|
* optional, retention for backup storage (default 3)
|
||||||
*
|
*
|
||||||
* @access admin
|
* @access admin
|
||||||
* @return string json-encoded array
|
* @return string json-encoded array
|
||||||
@@ -136,16 +145,39 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
// required parameters
|
// required parameters
|
||||||
$type = $this->getParam('type');
|
$type = $this->getParam('type');
|
||||||
$destination_path = $this->getParam('destination_path');
|
$destination_path = $this->getParam('destination_path');
|
||||||
|
$description = $this->getParam('description');
|
||||||
|
|
||||||
|
// type related requirements
|
||||||
|
$optional_flags = [
|
||||||
|
'region' => true,
|
||||||
|
'bucket' => true,
|
||||||
|
'hostname' => true,
|
||||||
|
'username' => true,
|
||||||
|
'password' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!in_array($type, self::SUPPORTED_TYPES)) {
|
||||||
|
throw new Exception("Unsupported storage type: '" . $type . "'", 406);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type != 'local') {
|
||||||
|
$optional_flags['hostname'] = false;
|
||||||
|
$optional_flags['username'] = false;
|
||||||
|
$optional_flags['password'] = false;
|
||||||
|
}
|
||||||
|
if ($type == 's3') {
|
||||||
|
$optional_flags['region'] = false;
|
||||||
|
$optional_flags['bucket'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
$description = $this->getParam('description', true, null);
|
$region = $this->getParam('region', $optional_flags['region']);
|
||||||
$region = $this->getParam('region', true, null);
|
$bucket = $this->getParam('bucket', $optional_flags['bucket']);
|
||||||
$bucket = $this->getParam('bucket', true, null);
|
$hostname = $this->getParam('hostname', $optional_flags['hostname']);
|
||||||
$hostname = $this->getParam('hostname', true, null);
|
$username = $this->getParam('username', $optional_flags['username']);
|
||||||
$username = $this->getParam('username', true, null);
|
$password = $this->getParam('password', $optional_flags['password']);
|
||||||
$password = $this->getParam('password', true, null);
|
|
||||||
$pgp_public_key = $this->getParam('pgp_public_key', true, null);
|
$pgp_public_key = $this->getParam('pgp_public_key', true, null);
|
||||||
$retention = $this->getParam('retention', true, null);
|
$retention = $this->getParam('retention', true, 3);
|
||||||
|
|
||||||
// validation
|
// validation
|
||||||
$destination_path = FileDir::makeCorrectDir(Validate::validate($destination_path, 'destination_path', Validate::REGEX_DIR, '', [], true));
|
$destination_path = FileDir::makeCorrectDir(Validate::validate($destination_path, 'destination_path', Validate::REGEX_DIR, '', [], true));
|
||||||
@@ -204,22 +236,22 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
];
|
];
|
||||||
Database::pexecute($stmt, $params, true, true);
|
Database::pexecute($stmt, $params, true, true);
|
||||||
$id = Database::lastInsertId();
|
$id = Database::lastInsertId();
|
||||||
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] edited backup storage for '" . $result['id'] . "'");
|
|
||||||
|
|
||||||
// return
|
// return
|
||||||
$result = $this->apiCall('BackupStorages.get', [
|
$result = $this->apiCall('BackupStorages.get', [
|
||||||
'id' => $id
|
'id' => $id
|
||||||
]);
|
]);
|
||||||
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] added backup storage '" . $result['description'] . "' (" . $result['type'] . ")");
|
||||||
return $this->response($result);
|
return $this->response($result);
|
||||||
}
|
}
|
||||||
throw new Exception("Not allowed to execute given command.", 403);
|
throw new Exception("Not allowed to execute given command.", 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return an admin entry by id
|
* return a backup storage entry by id
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* optional, the backup-storage-id
|
* the backup-storage-id
|
||||||
*
|
*
|
||||||
* @access admin
|
* @access admin
|
||||||
* @return string json-encoded array
|
* @return string json-encoded array
|
||||||
@@ -239,7 +271,7 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
];
|
];
|
||||||
$result = Database::pexecute_first($result_stmt, $params, true, true);
|
$result = Database::pexecute_first($result_stmt, $params, true, true);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] get backup storage for '" . $result['id'] . "'");
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] get backup storage '" . $result['description'] . "'");
|
||||||
return $this->response($result);
|
return $this->response($result);
|
||||||
}
|
}
|
||||||
throw new Exception("Backup storage with " . $id . " could not be found", 404);
|
throw new Exception("Backup storage with " . $id . " could not be found", 404);
|
||||||
@@ -253,25 +285,25 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* required, the backup-storage-id
|
* required, the backup-storage-id
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* backup storage type
|
* optional, backup storage type
|
||||||
* @param string $destination_path
|
* @param string $destination_path
|
||||||
* destination path for backup storage
|
* optional, destination path for backup storage
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* description for backup storage
|
* required, description for backup storage
|
||||||
* @param string $region
|
* @param string $region
|
||||||
* region for backup storage (used for S3)
|
* optional, region for backup storage (used for S3)
|
||||||
* @param string $bucket
|
* @param string $bucket
|
||||||
* bucket for backup storage (used for S3)
|
* optional, bucket for backup storage (used for S3)
|
||||||
* @param string $hostname
|
* @param string $hostname
|
||||||
* hostname for backup storage
|
* optional, hostname for backup storage
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* username for backup storage (also used as access key for S3)
|
* optional, username for backup storage (also used as access key for S3)
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* password for backup storage (also used as secret key for S3)
|
* optional, password for backup storage (also used as secret key for S3)
|
||||||
* @param string $pgp_public_key
|
* @param string $pgp_public_key
|
||||||
* pgp public key for backup storage
|
* optional, pgp public key for backup storage
|
||||||
* @param string $retention
|
* @param string $retention
|
||||||
* retention for backup storage
|
* optional, retention for backup storage (default 3)
|
||||||
*
|
*
|
||||||
* @access admin
|
* @access admin
|
||||||
* @return string json-encoded array
|
* @return string json-encoded array
|
||||||
@@ -295,16 +327,38 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
$destination_path = $this->getParam('destination_path', true, $result['destination_path']);
|
$destination_path = $this->getParam('destination_path', true, $result['destination_path']);
|
||||||
$hostname = $this->getParam('hostname', true, $result['hostname']);
|
$hostname = $this->getParam('hostname', true, $result['hostname']);
|
||||||
$username = $this->getParam('username', true, $result['username']);
|
$username = $this->getParam('username', true, $result['username']);
|
||||||
$password = $this->getParam('password', true, $result['password']);
|
$password = $this->getParam('password', true, '');
|
||||||
$pgp_public_key = $this->getParam('pgp_public_key', true, $result['pgp_public_key']);
|
$pgp_public_key = $this->getParam('pgp_public_key', true, $result['pgp_public_key']);
|
||||||
$retention = $this->getParam('retention', true, $result['retention']);
|
$retention = $this->getParam('retention', true, $result['retention']);
|
||||||
|
|
||||||
|
if (!in_array($type, self::SUPPORTED_TYPES)) {
|
||||||
|
throw new Exception("Unsupported storage type: '" . $type . "'", 406);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type != 'local') {
|
||||||
|
if (empty($hostname)) {
|
||||||
|
throw new Exception("Field 'hostname' cannot be empty", 406);
|
||||||
|
}
|
||||||
|
if (empty($username)) {
|
||||||
|
throw new Exception("Field 'username' cannot be empty", 406);
|
||||||
|
}
|
||||||
|
$password = Validate::validate($password, 'password', '', '', [], true);
|
||||||
|
}
|
||||||
|
if ($type == 's3') {
|
||||||
|
if (empty($region)) {
|
||||||
|
throw new Exception("Field 'region' cannot be empty", 406);
|
||||||
|
}
|
||||||
|
if (empty($bucket)) {
|
||||||
|
throw new Exception("Field 'bucket' cannot be empty", 406);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// validation
|
// validation
|
||||||
$destination_path = FileDir::makeCorrectDir(Validate::validate($destination_path, 'destination_path', Validate::REGEX_DIR, '', [], true));
|
$destination_path = FileDir::makeCorrectDir(Validate::validate($destination_path, 'destination_path', Validate::REGEX_DIR, '', [], true));
|
||||||
// TODO: add more validation
|
// TODO: add more validation
|
||||||
|
|
||||||
// pgp public key validation
|
// pgp public key validation
|
||||||
if (!empty($pgp_public_key)) {
|
if (!empty($pgp_public_key) && $pgp_public_key != $result['pgp_public_key']) {
|
||||||
// check if gnupg extension is loaded
|
// check if gnupg extension is loaded
|
||||||
if (!extension_loaded('gnupg')) {
|
if (!extension_loaded('gnupg')) {
|
||||||
Response::standardError('gnupgextensionnotavailable', '', true);
|
Response::standardError('gnupgextensionnotavailable', '', true);
|
||||||
@@ -316,6 +370,18 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($password)) {
|
||||||
|
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_BACKUP_STORAGES . "`
|
||||||
|
SET `password` = :password
|
||||||
|
WHERE `id` = :id
|
||||||
|
");
|
||||||
|
Database::pexecute($stmt, [
|
||||||
|
"id" => $id,
|
||||||
|
"password" => $password
|
||||||
|
], true, true);
|
||||||
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] updated password for backup-storage '" . $result['description'] . "'");
|
||||||
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
$stmt = Database::prepare("
|
$stmt = Database::prepare("
|
||||||
UPDATE `" . TABLE_PANEL_BACKUP_STORAGES . "`
|
UPDATE `" . TABLE_PANEL_BACKUP_STORAGES . "`
|
||||||
@@ -326,7 +392,6 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
`destination_path` = :destination_path,
|
`destination_path` = :destination_path,
|
||||||
`hostname` = :hostname,
|
`hostname` = :hostname,
|
||||||
`username` = :username,
|
`username` = :username,
|
||||||
`password` = :password,
|
|
||||||
`pgp_public_key` = :pgp_public_key,
|
`pgp_public_key` = :pgp_public_key,
|
||||||
`retention` = :retention
|
`retention` = :retention
|
||||||
WHERE `id` = :id
|
WHERE `id` = :id
|
||||||
@@ -340,12 +405,11 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
"destination_path" => $destination_path,
|
"destination_path" => $destination_path,
|
||||||
"hostname" => $hostname,
|
"hostname" => $hostname,
|
||||||
"username" => $username,
|
"username" => $username,
|
||||||
"password" => $password,
|
|
||||||
"pgp_public_key" => $pgp_public_key,
|
"pgp_public_key" => $pgp_public_key,
|
||||||
"retention" => $retention,
|
"retention" => $retention,
|
||||||
];
|
];
|
||||||
Database::pexecute($stmt, $params, true, true);
|
Database::pexecute($stmt, $params, true, true);
|
||||||
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] edited backup storage for '" . $result['id'] . "'");
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] edited backup storage '" . $result['description'] . "'");
|
||||||
|
|
||||||
// return
|
// return
|
||||||
$result = $this->apiCall('BackupStorages.get', [
|
$result = $this->apiCall('BackupStorages.get', [
|
||||||
@@ -376,6 +440,33 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
'id' => $id
|
'id' => $id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// validate no-one's using it
|
||||||
|
|
||||||
|
// settings
|
||||||
|
if ($id == Settings::Get('backup.default_storage')) {
|
||||||
|
throw new Exception("Given backup storage is currently set as default storage and cannot be deleted.", 406);
|
||||||
|
}
|
||||||
|
// customers
|
||||||
|
$sel_stmt = Database::prepare("
|
||||||
|
SELECT COUNT(*) as num_storage_users
|
||||||
|
FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
||||||
|
WHERE `backup` = :id
|
||||||
|
");
|
||||||
|
$storage_users_result = Database::pexecute_first($sel_stmt, ['id' => $id]);
|
||||||
|
if ($storage_users_result && $storage_users_result['num_storage_users'] > 0) {
|
||||||
|
throw new Exception("Given backup storage is currently assigned to " . $storage_users_result['num_storage_users'] . " customers and cannot be deleted.", 406);
|
||||||
|
}
|
||||||
|
// existing backups
|
||||||
|
$sel_stmt = Database::prepare("
|
||||||
|
SELECT COUNT(*) as num_storage_backups
|
||||||
|
FROM `" . TABLE_PANEL_BACKUPS . "`
|
||||||
|
WHERE `storage_id` = :id
|
||||||
|
");
|
||||||
|
$storage_backups_result = Database::pexecute_first($sel_stmt, ['id' => $id]);
|
||||||
|
if ($storage_backups_result && $storage_backups_result['num_storage_backups'] > 0) {
|
||||||
|
throw new Exception("Given backup storage has still " . $storage_backups_result['num_storage_backups'] . " backups on it and cannot be deleted.", 406);
|
||||||
|
}
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
$stmt = Database::prepare("
|
$stmt = Database::prepare("
|
||||||
DELETE FROM `" . TABLE_PANEL_BACKUP_STORAGES . "`
|
DELETE FROM `" . TABLE_PANEL_BACKUP_STORAGES . "`
|
||||||
@@ -385,7 +476,7 @@ class BackupStorages extends ApiCommand implements ResourceEntity
|
|||||||
"id" => $id
|
"id" => $id
|
||||||
];
|
];
|
||||||
Database::pexecute($stmt, $params, true, true);
|
Database::pexecute($stmt, $params, true, true);
|
||||||
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] deleted backup storage for '" . $result['id'] . "'");
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] deleted backup storage '" . $result['description'] . "'");
|
||||||
|
|
||||||
// return
|
// return
|
||||||
return $this->response(true);
|
return $this->response(true);
|
||||||
|
|||||||
@@ -43,37 +43,6 @@ use PDO;
|
|||||||
*/
|
*/
|
||||||
class Backups extends ApiCommand implements ResourceEntity
|
class Backups extends ApiCommand implements ResourceEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* increase resource-usage
|
|
||||||
*
|
|
||||||
* @param int $adminid
|
|
||||||
* @param string $resource
|
|
||||||
* @param string $extra
|
|
||||||
* optional, default empty
|
|
||||||
* @param int $increase_by
|
|
||||||
* optional, default 1
|
|
||||||
*/
|
|
||||||
public static function increaseUsage($adminid = 0, $resource = null, $extra = '', $increase_by = 1)
|
|
||||||
{
|
|
||||||
self::updateResourceUsage(TABLE_PANEL_BACKUPS, 'adminid', $adminid, '+', $resource, $extra, $increase_by);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* decrease resource-usage
|
|
||||||
*
|
|
||||||
* @param int $adminid
|
|
||||||
* @param string $resource
|
|
||||||
* @param string $extra
|
|
||||||
* optional, default empty
|
|
||||||
* @param int $decrease_by
|
|
||||||
* optional, default 1
|
|
||||||
*/
|
|
||||||
public static function decreaseUsage($adminid = 0, $resource = null, $extra = '', $decrease_by = 1)
|
|
||||||
{
|
|
||||||
self::updateResourceUsage(TABLE_PANEL_BACKUPS, 'adminid', $adminid, '-', $resource, $extra, $decrease_by);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lists all admin entries
|
* lists all admin entries
|
||||||
*
|
*
|
||||||
@@ -95,7 +64,7 @@ class Backups extends ApiCommand implements ResourceEntity
|
|||||||
public function listing()
|
public function listing()
|
||||||
{
|
{
|
||||||
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
|
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
|
||||||
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] list backups");
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] list backups");
|
||||||
$query_fields = [];
|
$query_fields = [];
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT `b`.*, `a`.`loginname` as `adminname`
|
SELECT `b`.*, `a`.`loginname` as `adminname`
|
||||||
|
|||||||
@@ -46,8 +46,10 @@ class ExportCron extends FroxlorCron
|
|||||||
");
|
");
|
||||||
$all_jobs = $result_tasks_stmt->fetchAll();
|
$all_jobs = $result_tasks_stmt->fetchAll();
|
||||||
|
|
||||||
|
if (!empty($all_jobs)) {
|
||||||
self::runFork([self::class, 'handle'], $all_jobs);
|
self::runFork([self::class, 'handle'], $all_jobs);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function handle(array $row)
|
public static function handle(array $row)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ return [
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'description' => [
|
'description' => [
|
||||||
'label' => lng('backup.backup_storage.description'),
|
'label' => lng('backup.backup_storage.description'),
|
||||||
'type' => 'text'
|
'type' => 'text',
|
||||||
|
'maxlength' => 200,
|
||||||
|
'mandatory' => true,
|
||||||
],
|
],
|
||||||
'type' => [
|
'type' => [
|
||||||
'label' => lng('backup.backup_storage.type'),
|
'label' => lng('backup.backup_storage.type'),
|
||||||
@@ -48,7 +50,8 @@ return [
|
|||||||
'sftp' => lng('backup.backup_storage.type_sftp'),
|
'sftp' => lng('backup.backup_storage.type_sftp'),
|
||||||
'rsync' => lng('backup.backup_storage.type_rsync'),
|
'rsync' => lng('backup.backup_storage.type_rsync'),
|
||||||
's3' => lng('backup.backup_storage.type_s3'),
|
's3' => lng('backup.backup_storage.type_s3'),
|
||||||
]
|
],
|
||||||
|
'mandatory' => true,
|
||||||
],
|
],
|
||||||
'region' => [
|
'region' => [
|
||||||
'label' => lng('backup.backup_storage.region'),
|
'label' => lng('backup.backup_storage.region'),
|
||||||
@@ -72,7 +75,8 @@ return [
|
|||||||
],
|
],
|
||||||
'password' => [
|
'password' => [
|
||||||
'label' => lng('backup.backup_storage.password'),
|
'label' => lng('backup.backup_storage.password'),
|
||||||
'type' => 'text'
|
'type' => 'password',
|
||||||
|
'autocomplete' => 'off',
|
||||||
],
|
],
|
||||||
'pgp_public_key' => [
|
'pgp_public_key' => [
|
||||||
'label' => lng('backup.backup_storage.pgp_public_key'),
|
'label' => lng('backup.backup_storage.pgp_public_key'),
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ return [
|
|||||||
'description' => [
|
'description' => [
|
||||||
'label' => lng('backup.backup_storage.description'),
|
'label' => lng('backup.backup_storage.description'),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'value' => $result['description']
|
'value' => $result['description'],
|
||||||
|
'mandatory' => true,
|
||||||
],
|
],
|
||||||
'type' => [
|
'type' => [
|
||||||
'label' => lng('backup.backup_storage.type'),
|
'label' => lng('backup.backup_storage.type'),
|
||||||
@@ -47,7 +48,8 @@ return [
|
|||||||
'sftp' => lng('backup.backup_storage.type_sftp'),
|
'sftp' => lng('backup.backup_storage.type_sftp'),
|
||||||
'rsync' => lng('backup.backup_storage.type_rsync'),
|
'rsync' => lng('backup.backup_storage.type_rsync'),
|
||||||
's3' => lng('backup.backup_storage.type_s3'),
|
's3' => lng('backup.backup_storage.type_s3'),
|
||||||
]
|
],
|
||||||
|
'mandatory' => true,
|
||||||
],
|
],
|
||||||
'region' => [
|
'region' => [
|
||||||
'label' => lng('backup.backup_storage.region'),
|
'label' => lng('backup.backup_storage.region'),
|
||||||
@@ -75,7 +77,7 @@ return [
|
|||||||
'value' => $result['username']
|
'value' => $result['username']
|
||||||
],
|
],
|
||||||
'password' => [
|
'password' => [
|
||||||
'label' => lng('backup.backup_storage.password'),
|
'label' => lng('backup.backup_storage.password') . ' (' . lng('panel.emptyfornochanges') . ')',
|
||||||
'type' => 'password',
|
'type' => 'password',
|
||||||
'autocomplete' => 'off'
|
'autocomplete' => 'off'
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user