mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 06:26:57 +00:00
allow to include volumes in backup and restore
Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
parent
1513d69a8d
commit
9f19026885
7 changed files with 68 additions and 23 deletions
|
|
@ -27,6 +27,8 @@ class Container {
|
|||
private array $capAdd;
|
||||
private int $shmSize;
|
||||
private bool $apparmorUnconfined;
|
||||
/** @var string[] */
|
||||
private array $backupVolumes;
|
||||
private DockerActionManager $dockerActionManager;
|
||||
|
||||
public function __construct(
|
||||
|
|
@ -45,6 +47,7 @@ class Container {
|
|||
array $capAdd,
|
||||
int $shmSize,
|
||||
bool $apparmorUnconfined,
|
||||
array $backupVolumes,
|
||||
DockerActionManager $dockerActionManager
|
||||
) {
|
||||
$this->identifier = $identifier;
|
||||
|
|
@ -62,6 +65,7 @@ class Container {
|
|||
$this->capAdd = $capAdd;
|
||||
$this->shmSize = $shmSize;
|
||||
$this->apparmorUnconfined = $apparmorUnconfined;
|
||||
$this->backupVolumes = $backupVolumes;
|
||||
$this->dockerActionManager = $dockerActionManager;
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +109,10 @@ class Container {
|
|||
return $this->capAdd;
|
||||
}
|
||||
|
||||
public function GetBackupVolumes() : array {
|
||||
return $this->backupVolumes;
|
||||
}
|
||||
|
||||
public function GetPorts() : ContainerPorts {
|
||||
return $this->ports;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,6 +228,11 @@ class ContainerDefinitionFetcher
|
|||
$apparmorUnconfined = $entry['apparmor_unconfined'];
|
||||
}
|
||||
|
||||
$backupVolumes = [];
|
||||
if (isset($entry['backup_volumes'])) {
|
||||
$backupVolumes = $entry['backup_volumes'];
|
||||
}
|
||||
|
||||
$containers[] = new Container(
|
||||
$entry['container_name'],
|
||||
$displayName,
|
||||
|
|
@ -244,6 +249,7 @@ class ContainerDefinitionFetcher
|
|||
$capAdd,
|
||||
$shmSize,
|
||||
$apparmorUnconfined,
|
||||
$backupVolumes,
|
||||
$this->container->get(DockerActionManager::class)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -429,6 +429,11 @@ class DockerActionManager
|
|||
if ($container->GetIdentifier() === 'nextcloud-aio-borgbackup') {
|
||||
// Additional backup directories
|
||||
$mounts = [];
|
||||
foreach ($this->getAllBackupVolumes() as $additionalBackupVolumes) {
|
||||
if ($additionalBackupVolumes !== '') {
|
||||
$mounts[] = ["Type" => "volume", "Source" => $additionalBackupVolumes, "Target" => "/nextcloud_aio_volumes/" . $additionalBackupVolumes, "ReadOnly" => false];
|
||||
}
|
||||
}
|
||||
foreach ($this->configurationManager->GetAdditionalBackupDirectoriesArray() as $additionalBackupDirectories) {
|
||||
if ($additionalBackupDirectories !== '') {
|
||||
if (!str_starts_with($additionalBackupDirectories, '/')) {
|
||||
|
|
@ -503,6 +508,24 @@ class DockerActionManager
|
|||
}
|
||||
}
|
||||
|
||||
private function getBackupVolumes(string $id) : array
|
||||
{
|
||||
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
||||
|
||||
$backupVolumes = $container->GetBackupVolumes();
|
||||
|
||||
foreach ($container->GetDependsOn() as $dependency) {
|
||||
$backupVolumes[] = $this->getBackupVolumes($dependency);
|
||||
}
|
||||
return $backupVolumes;
|
||||
}
|
||||
|
||||
private function getAllBackupVolumes() : array {
|
||||
$id = 'nextcloud-aio-apache';
|
||||
|
||||
return array_unique($this->getBackupVolumes($id));
|
||||
}
|
||||
|
||||
private function GetRepoDigestsOfContainer(string $containerName) : ?array {
|
||||
try {
|
||||
$containerUrl = $this->BuildApiUrl(sprintf('containers/%s/json', $containerName));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue