dgraph-io/dgraph · error

cannot export data inside DB at %s

Error message

cannot export data inside DB at %s

What it means

StoreExport opens a Badger DB over the export directory and runs exportInternal to stream data out. When the internal export fails for any reason (I/O error, corrupt manifest, encryption issues, badger errors), the failure is wrapped with the directory path so the developer knows which DB location could not be exported.

Source

Thrown at worker/backup.go:167

}

func StoreExport(request *pb.ExportRequest, dir string, key x.Sensitive) error {
	db, err := badger.OpenManaged(badger.DefaultOptions(dir).
		WithSyncWrites(false).
		WithValueThreshold(1 << 10).
		WithNumVersionsToKeep(math.MaxInt32).
		WithEncryptionKey(key))
	if err != nil {
		return err
	}
	defer func() {
		if err := db.Close(); err != nil {
			glog.Warningf("error closing the DB: %v", err)
		}
	}()

	_, err = exportInternal(context.Background(), request, db, true)
	return errors.Wrapf(err, "cannot export data inside DB at %s", dir)
}

// Backup handles a request coming from another node.
func (w *grpcWorker) Backup(ctx context.Context, req *pb.BackupRequest) (*pb.BackupResponse, error) {
	glog.V(2).Infof("Received backup request via Grpc: %+v", req)
	return backupCurrentGroup(ctx, req)
}

func backupCurrentGroup(ctx context.Context, req *pb.BackupRequest) (*pb.BackupResponse, error) {
	glog.Infof("Backup request: group %d at %d", req.GroupId, req.ReadTs)
	if err := ctx.Err(); err != nil {
		glog.Errorf("Context error during backup: %v\n", err)
		return nil, err
	}

	g := groups()
	if g.groupId() != req.GroupId {
		return nil, errors.Errorf("Backup request group mismatch. Mine: %d. Requested: %d\n",

View on GitHub (pinned to 759e242be6)

Solutions

  1. Check the wrapped (inner) error in the message for the root cause from exportInternal and fix that underlying issue first
  2. Verify the directory `dir` exists, is readable, and has free disk space
  3. Ensure the same x.Sensitive encryption key used when the DB was written is passed to StoreExport
  4. Re-run the export; if the dir is corrupt, regenerate it from a fresh backup/export

Example fix

// before
_, err = exportInternal(context.Background(), request, db, true)
return errors.Wrapf(err, "cannot export data inside DB at %s", dir)
// after
_, err = exportInternal(context.Background(), request, db, true)
if err != nil {
    glog.Errorf("export from %s failed: %v", dir, err) // log root cause before wrapping
}
return errors.Wrapf(err, "cannot export data inside DB at %s", dir)
Defensive patterns

Strategy: try-catch

Validate before calling

if info, err := os.Stat(dir); err != nil || !info.IsDir() {
    return fmt.Errorf("export dir %s missing or not a directory", dir)
}

Try / catch

if _, err := StoreExport(req, dir, key); err != nil {
    var root error = errors.Cause(err)
    glog.Errorf("export at %s failed: %v", dir, root)
    return root
}

Prevention

When it happens

Trigger: Calling StoreExport(request, dir, key) where badger.OpenManaged succeeded but exportInternal returned a non-nil error, e.g. reading a tablet/DB at `dir` fails mid-stream or the export pipeline hits an I/O or decode error.

Common situations: Exporting from a partially written or corrupted export directory; disk full or permission problems on the export dir; encryption key mismatch between what was used to write the DB and the `key` passed to StoreExport; interrupted prior export leaving the DB in a bad state.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/c1c71301ee689a58. Report an issue: GitHub.