36e6a3fde7
- AdminApiController (admin only, CSRF-protected): status, create key, download recovery kit, confirm (statement accepted + exact phrase), backends with their usable auth mechanisms, add/test/remove locations, start backups, schedule, snapshots, browse, queue restores - RestoreJob runs web-initiated restores in the background; backup and restore runs are kept apart in the run table - admin section 'NG Backup' with a Vue 3 / @nextcloud/vue 9 page: key and recovery-kit flow (download, tick statement, 'Yes, I confirm'), location form built from files_external's parameter definitions, schedule, run list with polling, snapshot browser and restore with the three modes - auth mechanisms that depend on a user session or on files_external's own stored credentials are not offered API tested with curl on NC34 (status, backends, schedule validation, confirmation refusal, browse, queued restore and backup completed by cron); non-admins get 403, anonymous 401.
49 lines
1.5 KiB
PHP
49 lines
1.5 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 OC\Core\Command\Base;
|
|
use OCA\NgBackup\Service\TargetService;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
class TargetBackends extends Base {
|
|
public function __construct(
|
|
private TargetService $targets,
|
|
) {
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function configure(): void {
|
|
parent::configure();
|
|
$this->setName('backup:target:backends')
|
|
->setDescription('List the storage backends (from files_external) that can be used as backup location');
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
|
$backends = $this->targets->availableBackends();
|
|
if ($input->getOption('output') !== self::OUTPUT_FORMAT_PLAIN) {
|
|
$this->writeMixedInOutputFormat($input, $output, $backends);
|
|
return 0;
|
|
}
|
|
foreach ($backends as $b) {
|
|
$output->writeln(sprintf('<info>%s</info> (%s)', $b['id'], $b['name']));
|
|
foreach ($b['parameters'] as $key => $p) {
|
|
$output->writeln(sprintf(' -o %s=... %s', $key, is_array($p) ? ($p['value'] ?? '') : ''));
|
|
}
|
|
foreach ($b['auth'] as $a) {
|
|
$output->writeln(sprintf(' -a %s (%s)', $a['id'], $a['name']));
|
|
foreach ($a['parameters'] as $key => $p) {
|
|
$output->writeln(sprintf(' -o %s=... %s', $key, is_array($p) ? ($p['value'] ?? '') : ''));
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
}
|