7b154e322b
- notifications to administrators for failed backup/restore runs and locations without a successful backup for two days (once a day) - setup check in the admin overview: error when the key/kit is not set up, warning for missing, old or failed backups - security events (recovery kit downloaded, location removed, append-only turned off, retention changed, snapshots forgotten) go to the audit log and are announced to all administrators, from the web and from occ; the scheduled weekly cleanup is logged only - fix: the recovery-kit download link failed the CSRF check (412); it now requires a recent password confirmation instead, like creating the key, removing a location and restoring
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
// SPDX-FileCopyrightText: 2026 Dillard Blom
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
namespace OCA\NgBackup\Command;
|
|
|
|
use OCA\NgBackup\Service\TargetService;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
class TargetRemove extends Command {
|
|
public function __construct(
|
|
private TargetService $targets,
|
|
private \OCA\NgBackup\Service\AlertService $alerts,
|
|
) {
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function configure(): void {
|
|
$this->setName('backup:target:remove')
|
|
->setDescription('Remove a backup location from NG Backup (the backups on it are kept)')
|
|
->addArgument('target', InputArgument::REQUIRED, 'Name or id');
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
|
try {
|
|
$t = $this->targets->get($input->getArgument('target'));
|
|
} catch (\Throwable) {
|
|
$output->writeln('<error>No such location.</error>');
|
|
return 1;
|
|
}
|
|
$this->targets->remove($t);
|
|
$this->alerts->securityEvent('target_removed', ['target' => $t->getName()]);
|
|
$output->writeln('Removed <info>' . $t->getName() . '</info>. The backups on the location itself were not touched; add it again to use them.');
|
|
return 0;
|
|
}
|
|
}
|