mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 12:55:18 +00:00
check: Complain about usage of s3 legacy layout
This commit is contained in:
parent
8b8bd4e8ac
commit
fcb3ddf181
@ -260,10 +260,12 @@ func runCheck(opts CheckOptions, gopts GlobalOptions, args []string) error {
|
||||
if checker.IsOrphanedPack(err) {
|
||||
orphanedPacks++
|
||||
Verbosef("%v\n", err)
|
||||
continue
|
||||
} else if _, ok := err.(*checker.ErrLegacyLayout); ok {
|
||||
Verbosef("repository still uses the S3 legacy layout\nPlease run `restic migrate s3legacy` to correct this.\n")
|
||||
} else {
|
||||
errorsFound = true
|
||||
Warnf("%v\n", err)
|
||||
}
|
||||
errorsFound = true
|
||||
Warnf("error: %v\n", err)
|
||||
}
|
||||
|
||||
if orphanedPacks > 0 {
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/minio/sha256-simd"
|
||||
"github.com/restic/restic/internal/backend"
|
||||
"github.com/restic/restic/internal/backend/s3"
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/hashing"
|
||||
@ -56,6 +57,13 @@ func New(repo restic.Repository, trackUnused bool) *Checker {
|
||||
return c
|
||||
}
|
||||
|
||||
// ErrLegacyLayout is returned when the repository uses the S3 legacy layout.
|
||||
type ErrLegacyLayout struct{}
|
||||
|
||||
func (e *ErrLegacyLayout) Error() string {
|
||||
return "repository uses S3 legacy layout"
|
||||
}
|
||||
|
||||
// ErrDuplicatePacks is returned when a pack is found in more than one index.
|
||||
type ErrDuplicatePacks struct {
|
||||
PackID restic.ID
|
||||
@ -184,12 +192,25 @@ func IsOrphanedPack(err error) bool {
|
||||
return errors.As(err, &e) && e.Orphaned
|
||||
}
|
||||
|
||||
func isS3Legacy(b restic.Backend) bool {
|
||||
be, ok := b.(*s3.Backend)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
return be.Layout.Name() == "s3legacy"
|
||||
}
|
||||
|
||||
// Packs checks that all packs referenced in the index are still available and
|
||||
// there are no packs that aren't in an index. errChan is closed after all
|
||||
// packs have been checked.
|
||||
func (c *Checker) Packs(ctx context.Context, errChan chan<- error) {
|
||||
defer close(errChan)
|
||||
|
||||
if isS3Legacy(c.repo.Backend()) {
|
||||
errChan <- &ErrLegacyLayout{}
|
||||
}
|
||||
|
||||
debug.Log("checking for %d packs", len(c.packs))
|
||||
|
||||
debug.Log("listing repository packs")
|
||||
|
Loading…
Reference in New Issue
Block a user