mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-19 14:06:50 +00:00
refactor backup-mode handling
Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
parent
01ad594ec5
commit
57306c8cae
3 changed files with 14 additions and 27 deletions
|
|
@ -104,7 +104,7 @@ $app->get('/containers', function (Request $request, Response $response, array $
|
|||
'is_backup_container_running' => $dockerActionManger->isBackupContainerRunning(),
|
||||
'backup_exit_code' => $dockerActionManger->GetBackupcontainerExitCode(),
|
||||
'is_instance_restore_attempt' => $configurationManager->isInstanceRestoreAttempt(),
|
||||
'borg_backup_mode' => $configurationManager->GetBorgBackupMode(),
|
||||
'borg_backup_mode' => $configurationManager->GetBackupMode(),
|
||||
'was_start_button_clicked' => $configurationManager->wasStartButtonClicked(),
|
||||
'has_update_available' => $dockerActionManger->isAnyUpdateAvailable(),
|
||||
'last_backup_time' => $configurationManager->GetLastBackupTime(),
|
||||
|
|
|
|||
|
|
@ -89,9 +89,7 @@ readonly class DockerController {
|
|||
}
|
||||
|
||||
public function startBackup(bool $forceStopNextcloud = false) : void {
|
||||
$config = $this->configurationManager->GetConfig();
|
||||
$config['backup-mode'] = 'backup';
|
||||
$this->configurationManager->WriteConfig($config);
|
||||
$this->configurationManager->SetBackupMode('backup');
|
||||
|
||||
$id = self::TOP_CONTAINER;
|
||||
$this->PerformRecursiveContainerStop($id, $forceStopNextcloud);
|
||||
|
|
@ -111,26 +109,22 @@ readonly class DockerController {
|
|||
}
|
||||
|
||||
public function checkBackup() : void {
|
||||
$config = $this->configurationManager->GetConfig();
|
||||
$config['backup-mode'] = 'check';
|
||||
$this->configurationManager->WriteConfig($config);
|
||||
$this->configurationManager->SetBackupMode('check');
|
||||
|
||||
$id = 'nextcloud-aio-borgbackup';
|
||||
$this->PerformRecursiveContainerStart($id);
|
||||
}
|
||||
|
||||
private function listBackup() : void {
|
||||
$config = $this->configurationManager->GetConfig();
|
||||
$config['backup-mode'] = 'list';
|
||||
$this->configurationManager->WriteConfig($config);
|
||||
$this->configurationManager->SetBackupMode('list');
|
||||
|
||||
$id = 'nextcloud-aio-borgbackup';
|
||||
$this->PerformRecursiveContainerStart($id);
|
||||
}
|
||||
|
||||
public function StartBackupContainerRestore(Request $request, Response $response, array $args) : Response {
|
||||
$this->configurationManager->SetBackupMode('restore');
|
||||
$config = $this->configurationManager->GetConfig();
|
||||
$config['backup-mode'] = 'restore';
|
||||
$config['selected-restore-time'] = $request->getParsedBody()['selected_restore_time'] ?? '';
|
||||
if (isset($request->getParsedBody()['restore-exclude-previews'])) {
|
||||
$config['restore-exclude-previews'] = 1;
|
||||
|
|
@ -150,24 +144,20 @@ readonly class DockerController {
|
|||
}
|
||||
|
||||
public function StartBackupContainerCheckRepair(Request $request, Response $response, array $args) : Response {
|
||||
$config = $this->configurationManager->GetConfig();
|
||||
$config['backup-mode'] = 'check-repair';
|
||||
$this->configurationManager->WriteConfig($config);
|
||||
$this->configurationManager->SetBackupMode('check-repair');
|
||||
|
||||
$id = 'nextcloud-aio-borgbackup';
|
||||
$this->PerformRecursiveContainerStart($id);
|
||||
|
||||
// Restore to backup check which is needed to make the UI logic work correctly
|
||||
$config = $this->configurationManager->GetConfig();
|
||||
$config['backup-mode'] = 'check';
|
||||
$this->configurationManager->WriteConfig($config);
|
||||
$this->configurationManager->SetBackupMode('check');
|
||||
|
||||
return $response->withStatus(201)->withHeader('Location', '.');
|
||||
}
|
||||
|
||||
public function StartBackupContainerTest(Request $request, Response $response, array $args) : Response {
|
||||
$this->configurationManager->SetBackupMode('test');
|
||||
$config = $this->configurationManager->GetConfig();
|
||||
$config['backup-mode'] = 'test';
|
||||
$config['instance_restore_attempt'] = 0;
|
||||
$this->configurationManager->WriteConfig($config);
|
||||
|
||||
|
|
|
|||
|
|
@ -423,6 +423,12 @@ class ConfigurationManager
|
|||
return $config['backup-mode'];
|
||||
}
|
||||
|
||||
public function SetBackupMode(string $mode) : void {
|
||||
$config = $this->GetConfig();
|
||||
$config['backup-mode'] = $mode;
|
||||
$this->WriteConfig($config);
|
||||
}
|
||||
|
||||
public function GetSelectedRestoreTime() : string {
|
||||
$config = $this->GetConfig();
|
||||
if(!isset($config['selected-restore-time'])) {
|
||||
|
|
@ -664,15 +670,6 @@ class ConfigurationManager
|
|||
return false;
|
||||
}
|
||||
|
||||
public function GetBorgBackupMode() : string {
|
||||
$config = $this->GetConfig();
|
||||
if(!isset($config['backup-mode'])) {
|
||||
$config['backup-mode'] = '';
|
||||
}
|
||||
|
||||
return $config['backup-mode'];
|
||||
}
|
||||
|
||||
public function GetNextcloudMount() : string {
|
||||
$envVariableName = 'NEXTCLOUD_MOUNT';
|
||||
$configName = 'nextcloud_mount';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue