Skip to content

Modern Docker Management, Designed for Everyone

fix: skip volume backup prune when the local repository was never created (#4448)

Giulio Savini1ff65354b874
diff --git a/backend/internal/volume/children/backup/helpers.go b/backend/internal/volume/children/backup/helpers.go
index 13d82fede..8dd6fc422 100644
--- a/backend/internal/volume/children/backup/helpers.go
+++ b/backend/internal/volume/children/backup/helpers.go
@@ -5,7 +5,10 @@ import (
"context"
"errors"
"fmt"
+ "io/fs"
"log/slog"
+ "os"
+ "path"
"slices"
"strings"
"time"
@@ -53,6 +56,18 @@ func resolveBackupStorageMountFromMounts(ctx context.Context, mounts []container
return mirroredMount
}
+// localRusticRepositoryInitialized reports whether the local volume repository
+// has a Rustic config file. Only a /backups mount in the Arcane container can be
+// checked without starting Rustic, so any other setup counts as initialized.
+func (s *Service) localRusticRepositoryInitialized(ctx context.Context, dockerClient *client.Client) bool {
+ inspect, err := libarcane.InspectCurrentArcaneContainer(ctx, dockerClient)
+ if err != nil || docker.MountForDestination(inspect.Mounts, "/backups", "/backups") == nil {
+ return true
+ }
+ _, err = os.Stat(path.Join("/backups", path.Base(volumeRusticRepositoryPath), "config"))
+ return !errors.Is(err, fs.ErrNotExist)
+}
+
// backupMountWarningFromArcaneMounts warns unless Arcane mounts /backups; a /restores mount also suppresses it for compatibility.
func backupMountWarningFromArcaneMounts(mounts []container.MountPoint) string {
restoresMounted := slices.ContainsFunc(mounts, func(m container.MountPoint) bool { return m.Destination == "/restores" })
diff --git a/backend/internal/volume/children/backup/service.go b/backend/internal/volume/children/backup/service.go
index e567099b4..b26856b2f 100644
--- a/backend/internal/volume/children/backup/service.go
+++ b/backend/internal/volume/children/backup/service.go
@@ -687,6 +687,10 @@ func (s *Service) PruneLocalRepository(ctx context.Context) error {
if err != nil {
return err
}
+ // Skip before re-keying, which would start Rustic against a missing repository.
+ if !s.localRusticRepositoryInitialized(ctx, dockerClient) {
+ return nil
+ }
repository, err := s.localRusticRepository(ctx, dockerClient, false)
if err != nil {
return err