thanos-io/thanos · error

dir seems to exists in backup bucket. Remove this block…

Error message

%s dir seems to exists in backup bucket. Remove this block manually if you are sure it is safe to do

What it means

BackupAndDelete refuses to proceed when TSDBBlockExistsInBucket reports the block already present in the backup bucket, returning the fixed error "<id> dir seems to exists in backup bucket. Remove this block manually...". This is a safety guard against overwriting or mixing backups; the delete is aborted.

Solutions

  1. Confirm the existing backup-bucket copy of the block is complete and identical to the source block.
  2. If it is a valid backup, manually remove the block dir from the backup bucket, then re-run the delete.
  3. Use a dedicated per-run backup bucket/prefix to avoid collisions.
  4. Never point the backup bucket at a bucket whose contents you cannot verify.

Example fix

// before: shared backup bucket retaining old copy
--backup-bucket=thanos-backup
// after: clean or per-run backup location
--backup-bucket=thanos-backup/run-2026-09-06
Defensive patterns

Strategy: validation

Validate before calling

found, err := verifier.TSDBBlockExistsInBucket(ctx, backupBkt, id)
if found { return fmt.Errorf("clean backup bucket entry for %s before safe-delete", id) }

Try / catch

if err := verifier.VerifyRepair(...); err != nil {
    if strings.Contains(err.Error(), "seems to exists in backup bucket") {
        // manually verify and remove the stale backup copy, then re-run
    }
}

Prevention

When it happens

Trigger: Running VerifyRepair with safe-delete when a previous run already backed up the same block ID (interrupted earlier attempt), or two verify runs sharing one backup bucket concurrently.

Common situations: Re-running the verifier after a failed/partial safe-delete; sharing a backup bucket across environments/compactors; manual retries after fixing transient failures without cleaning the backup.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/dfca9da93fc958f3. Report an issue: GitHub.

Appendix: source

Thrown at pkg/verifier/safe_delete.go:50

	})

	return foundDir, err
}

// BackupAndDelete moves a TSDB block to a backup bucket and on success removes
// it from the source bucket. If deleteDelay is zero, block is removed from source bucket.
// else the block is marked for deletion.
// It returns error if block dir already exists in
// the backup bucket (blocks should be immutable) or if any of the operations
// fail.
func BackupAndDelete(ctx Context, id ulid.ULID) error {
	// Does this TSDB block exist in backupBkt already?
	found, err := TSDBBlockExistsInBucket(ctx, ctx.BackupBkt, id)
	if err != nil {
		return err
	}
	if found {
		return errors.Errorf("%s dir seems to exists in backup bucket. Remove this block manually if you are sure it is safe to do", id)
	}

	// Create a tempdir to locally store TSDB block.
	tempdir, err := os.MkdirTemp("", fmt.Sprintf("safe-delete-%s", id.String()))
	if err != nil {
		return err
	}
	defer func() {
		if err := os.RemoveAll(tempdir); err != nil {
			level.Warn(ctx.Logger).Log("msg", "failed to delete dir", "dir", tempdir, "err", err)
		}
	}()

	// Download the TSDB block.
	dir := filepath.Join(tempdir, id.String())
	if err := block.Download(ctx, ctx.Logger, ctx.Bkt, id, dir); err != nil {
		return errors.Wrap(err, "download from source")
	}

View on GitHub (pinned to 35b8b99117)