From f897bd2d06f445e9c4e2ecc0c2bb91c8fb695002 Mon Sep 17 00:00:00 2001 From: estebanthi Date: Tue, 7 Oct 2025 17:10:24 +0200 Subject: [PATCH 1/3] Ensure destination exists when using SSH storage --- internal/storage/ssh/ssh.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/storage/ssh/ssh.go b/internal/storage/ssh/ssh.go index 299052cd..60654e24 100644 --- a/internal/storage/ssh/ssh.go +++ b/internal/storage/ssh/ssh.go @@ -107,6 +107,10 @@ func (b *sshStorage) Name() string { // Copy copies the given file to the SSH storage backend. func (b *sshStorage) Copy(file string) (returnErr error) { + if err := b.sftpClient.MkdirAll(b.DestinationPath); err != nil { + return errwrap.Wrap(err, "error ensuring destination directory") + } + source, err := os.Open(file) _, name := path.Split(file) if err != nil { @@ -170,6 +174,10 @@ func (b *sshStorage) Copy(file string) (returnErr error) { func (b *sshStorage) Prune(deadline time.Time, pruningPrefix string) (*storage.PruneStats, error) { candidates, err := b.sftpClient.ReadDir(b.DestinationPath) if err != nil { + // If directory doesn't exist yet, nothing to prune + if errors.Is(err, os.ErrNotExist) { + return &storage.PruneStats{}, nil + } return nil, errwrap.Wrap(err, "error reading directory") } From 8934eee64c4f303cef79cbba0930e61bb0c8a67e Mon Sep 17 00:00:00 2001 From: estebanthi Date: Tue, 7 Oct 2025 22:09:28 +0200 Subject: [PATCH 2/3] Import "errors" --- internal/storage/ssh/ssh.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/storage/ssh/ssh.go b/internal/storage/ssh/ssh.go index 60654e24..8bbd004f 100644 --- a/internal/storage/ssh/ssh.go +++ b/internal/storage/ssh/ssh.go @@ -4,6 +4,7 @@ package ssh import ( + "errors" "fmt" "io" "os" From 52bf9d83d69f5725276602347d9517ad484c4d6b Mon Sep 17 00:00:00 2001 From: estebanthi Date: Tue, 7 Oct 2025 22:11:36 +0200 Subject: [PATCH 3/3] New feature doc --- docs/reference/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/index.md b/docs/reference/index.md index 08e27e02..6a655ffa 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -278,6 +278,7 @@ The values for each key currently match its default. # --- # The Directory to place the backups to on the SSH server. +# If the directory does not exist, it will be created automatically. # Example: "/home/user/backups" # SSH_REMOTE_PATH=""