{"record":{"id":"dfca9da93fc958f3","repo":"thanos-io/thanos","slug":"s-dir-seems-to-exists-in-backup-bucket-remove-th","errorCode":null,"errorMessage":"%s dir seems to exists in backup bucket. Remove this block manually if you are sure it is safe to do","messagePattern":"(.+?) dir seems to exists in backup bucket\\. Remove this block manually if you are sure it is safe to do","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/verifier/safe_delete.go","lineNumber":50,"sourceCode":"\t})\n\n\treturn foundDir, err\n}\n\n// BackupAndDelete moves a TSDB block to a backup bucket and on success removes\n// it from the source bucket. If deleteDelay is zero, block is removed from source bucket.\n// else the block is marked for deletion.\n// It returns error if block dir already exists in\n// the backup bucket (blocks should be immutable) or if any of the operations\n// fail.\nfunc BackupAndDelete(ctx Context, id ulid.ULID) error {\n\t// Does this TSDB block exist in backupBkt already?\n\tfound, err := TSDBBlockExistsInBucket(ctx, ctx.BackupBkt, id)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif found {\n\t\treturn errors.Errorf(\"%s dir seems to exists in backup bucket. Remove this block manually if you are sure it is safe to do\", id)\n\t}\n\n\t// Create a tempdir to locally store TSDB block.\n\ttempdir, err := os.MkdirTemp(\"\", fmt.Sprintf(\"safe-delete-%s\", id.String()))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif err := os.RemoveAll(tempdir); err != nil {\n\t\t\tlevel.Warn(ctx.Logger).Log(\"msg\", \"failed to delete dir\", \"dir\", tempdir, \"err\", err)\n\t\t}\n\t}()\n\n\t// Download the TSDB block.\n\tdir := filepath.Join(tempdir, id.String())\n\tif err := block.Download(ctx, ctx.Logger, ctx.Bkt, id, dir); err != nil {\n\t\treturn errors.Wrap(err, \"download from source\")\n\t}","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/verifier/safe_delete.go#L32-L68","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the existing backup-bucket copy of the block is complete and identical to the source block.","If it is a valid backup, manually remove the block dir from the backup bucket, then re-run the delete.","Use a dedicated per-run backup bucket/prefix to avoid collisions.","Never point the backup bucket at a bucket whose contents you cannot verify."],"exampleFix":"// before: shared backup bucket retaining old copy\n--backup-bucket=thanos-backup\n// after: clean or per-run backup location\n--backup-bucket=thanos-backup/run-2026-09-06","handlingStrategy":"validation","validationCode":"found, err := verifier.TSDBBlockExistsInBucket(ctx, backupBkt, id)\nif found { return fmt.Errorf(\"clean backup bucket entry for %s before safe-delete\", id) }","typeGuard":null,"tryCatchPattern":"if err := verifier.VerifyRepair(...); err != nil {\n    if strings.Contains(err.Error(), \"seems to exists in backup bucket\") {\n        // manually verify and remove the stale backup copy, then re-run\n    }\n}","preventionTips":["Use a fresh or namespaced backup bucket per run","Check the backup bucket before re-running failed safe-deletes","Never share one backup bucket across concurrent verifier runs"],"tags":["go","backup","object-storage","safety-guard","thanos"],"backgroundTag":"file-already-exists","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}