{"record":{"id":"70846216277eb4c0","repo":"dgraph-io/dgraph","slug":"while-creating-backup-directory","errorCode":null,"errorMessage":"while creating backup directory","messagePattern":"while creating backup directory","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/backup.go","lineNumber":278,"sourceCode":"\t\tglog.Errorf(\"Unable to retrieve readonly timestamp for backup: %s\", err)\n\t\treturn err\n\t}\n\n\treq.ReadTs = ts.ReadOnly\n\treq.UnixTs = time.Now().UTC().Format(\"20060102.150405.000\")\n\n\t// Read the manifests to get the right timestamp from which to start the backup.\n\turi, err := url.Parse(req.Destination)\n\tif err != nil {\n\t\treturn err\n\t}\n\thandler, err := NewUriHandler(uri, GetCredentialsFromRequest(req))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !handler.DirExists(\"./\") {\n\t\tif err := handler.CreateDir(\"./\"); err != nil {\n\t\t\treturn errors.Wrap(err, \"while creating backup directory\")\n\t\t}\n\t}\n\tlatestManifest, err := GetLatestManifest(handler, uri)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq.SinceTs = latestManifest.ValidReadTs()\n\t// To force a full backup we'll set the sinceTs to zero.\n\tif req.ForceFull {\n\t\treq.SinceTs = 0\n\t} else {\n\t\tif err := checkBackupReadTsAdvanced(latestManifest, req.ReadTs); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif x.WorkerConfig.EncryptionKey != nil {\n\t\t\t// If encryption key given, latest backup should be encrypted.","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/backup.go#L260-L296","documentation":"ProcessBackupRequest ensures the destination directory exists at the backup URI before writing. If handler.DirExists(\"./\") reports the directory missing and handler.CreateDir(\"./\") then fails (permissions, bucket missing, storage backend error), the error is wrapped with this message.","triggerScenarios":"Running a backup to a URI whose target directory does not yet exist and the storage handler cannot create it — e.g. S3/MinIO bucket missing, wrong access keys lacking PutObject/CreateDir permission, or an invalid filesystem path.","commonSituations":"S3 bucket name typo; IAM credentials without write permission to the prefix; s3:// or minio:// URI malformed; local filesystem path on a read-only volume; running container without write access to the mounted path.","solutions":["Check the wrapped inner error for the storage backend's root cause","Verify the backup URI (bucket/path) is correct and the bucket exists","Confirm credentials have write/CreateDir permissions on the destination","Pre-create the destination directory/bucket manually, then re-run the backup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"handler, err := NewUriHandler(u, creds)\nif err != nil { return err }\nif !handler.DirExists(\"./\") {\n    if err := handler.CreateDir(\"./\"); err != nil {\n        return fmt.Errorf(\"pre-check: cannot create backup dir at %s: %w\", u, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := ProcessBackupRequest(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"while creating backup directory\") {\n    // check URI validity, bucket existence, and write permissions before retry\n}","preventionTips":["Pre-create the destination bucket/prefix with correct permissions","Validate the backup URI scheme and path before running backups","Grant backup credentials write access (s3:PutObject) to the destination","Test the destination with a small write before scheduling large backups"],"tags":["backup","storage","s3","permissions"],"backgroundTag":"backup-directory-creation-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}