allow to restore the whole instance from backup

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-03-21 13:23:17 +01:00
parent 6aa0b7097a
commit 6c6c56fa1b
11 changed files with 199 additions and 28 deletions

View file

@ -237,6 +237,8 @@ class ConfigurationManager
// Write domain
$config = $this->GetConfig();
$config['domain'] = $domain;
// Reset the borg restore password when setting the domain
$config['borg_restore_password'] = '';
$this->WriteConfig($config);
}
@ -308,6 +310,33 @@ class ConfigurationManager
$this->WriteConfig($config);
}
/**
* @throws InvalidSettingConfigurationException
*/
public function SetBorgRestoreHostLocationAndPassword(string $location, string $password) : void {
if ($location === '') {
throw new InvalidSettingConfigurationException("Please enter a path!");
}
$isValidPath = false;
if (str_starts_with($location, '/') && !str_ends_with($location, '/')) {
$isValidPath = true;
}
if(!$isValidPath) {
throw new InvalidSettingConfigurationException("The path may start with '/mnt/', '/media/' or '/host_mnt/' or may be equal to '/var/backups'.");
}
if ($password === '') {
throw new InvalidSettingConfigurationException("Please enter the password!");
}
$config = $this->GetConfig();
$config['borg_backup_host_location'] = $location;
$config['borg_restore_password'] = $password;
$this->WriteConfig($config);
}
/**
* @throws InvalidSettingConfigurationException
*/
@ -384,6 +413,15 @@ class ConfigurationManager
return $config['borg_backup_host_location'];
}
public function GetBorgRestorePassword() : string {
$config = $this->GetConfig();
if(!isset($config['borg_restore_password'])) {
$config['borg_restore_password'] = '';
}
return $config['borg_restore_password'];
}
public function GetBorgBackupMode() : string {
$config = $this->GetConfig();
if(!isset($config['backup-mode'])) {