Exclude specific backends from pruning (#262)

* Skip backends while pruning

* Add pruning test step and silence download log for better readability

* Add test cases for pruning in all backends

Also add -q or --quiet-pull to all tests.

* Add test case for skipping backends while pruning

* Adjusted test logging, generate new test spec file

* Gitignore for temp test file
This commit is contained in:
MaxJa4
2023-08-27 19:19:11 +02:00
committed by GitHub
parent 5fcc96edf9
commit ad4e2af83f
25 changed files with 330 additions and 40 deletions

View File

@@ -14,6 +14,8 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strings"
"text/template"
"time"
@@ -591,6 +593,12 @@ func (s *script) pruneBackups() error {
for _, backend := range s.storages {
b := backend
eg.Go(func() error {
if skipPrune(b.Name(), s.c.BackupSkipBackendsFromPrune) {
s.logger.Info(
fmt.Sprintf("Skipping pruning for backend `%s`.", b.Name()),
)
return nil
}
stats, err := b.Prune(deadline, s.c.BackupPruningPrefix)
if err != nil {
return err
@@ -622,3 +630,14 @@ func (s *script) must(err error) {
panic(err)
}
}
// skipPrune returns true if the given backend name is contained in the
// list of skipped backends.
func skipPrune(name string, skippedBackends []string) bool {
return slices.ContainsFunc(
skippedBackends,
func(b string) bool {
return strings.EqualFold(b, name) // ignore case on both sides
},
)
}