Skip to content

Commit

Permalink
Merge pull request #80510 from benbardin/backport21.2-80182
Browse files Browse the repository at this point in the history
release-21.2: backupccl: Fix SHOW BACKUPS on a bucket's base directory
  • Loading branch information
benbardin authored Apr 26, 2022
2 parents 39511c6 + b912939 commit 976853d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/ccl/backupccl/manifest_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"io/ioutil"
"net/url"
"path"
"regexp"
"sort"
"strings"

Expand Down Expand Up @@ -83,6 +84,11 @@ const (
latestFileName = "LATEST"
)

// On some cloud storage platforms (i.e. GS, S3), backups in a base bucket may
// omit a leading slash. However, backups in a subdirectory of a base bucket
// will contain one.
var backupPathRE = regexp.MustCompile("^/?[^\\/]+/[^\\/]+/[^\\/]+/" + backupManifestName + "$")

var errEncryptionInfoRead = errors.New(`ENCRYPTION-INFO not found`)

// isGZipped detects whether the given bytes represent GZipped data. This check
Expand Down Expand Up @@ -1057,13 +1063,12 @@ func ListFullBackupsInCollection(
) ([]string, error) {
var backupPaths []string
if err := store.List(ctx, "", listingDelimDataSlash, func(f string) error {
if ok, err := path.Match("/*/*/*/"+backupManifestName, f); err != nil {
return err
} else if ok {
if backupPathRE.MatchString(f) {
backupPaths = append(backupPaths, f)
}
return nil
}); err != nil {
// Can't happen, just required to handle the error for lint.
return nil, err
}
for i, backupPath := range backupPaths {
Expand Down

0 comments on commit 976853d

Please sign in to comment.