dgraph-io/dgraph · error

newBackupReader

Error message

newBackupReader

What it means

readerFrom builds a backup reader for the per-group backup file (backupName at manifest.ValidReadTs); any error constructing it (missing object, unreadable stream, decryption/compression setup failure) is stored on the reader's err field and re-surfaced by RunMapper wrapped as 'newBackupReader'.

Source

Thrown at worker/restore_map.go:825

		if dropAll {
			break
		}
		if manifest.ValidReadTs() == 0 || len(manifest.Groups) == 0 {
			continue
		}
		for gid := range manifest.Groups {
			if gid != req.GroupId {
				// LoadBackup will try to call the backup function for every group.
				// Exit here if the group is not the one indicated by the request.
				continue
			}

			// Only restore the predicates that were assigned to this group at the time
			// of the last backup.
			file := filepath.Join(manifest.Path, backupName(manifest.ValidReadTs(), gid))
			br := readerFrom(h, file).WithEncryption(keys.EncKey).WithCompression(manifest.Compression)
			if br.err != nil {
				return nil, errors.Wrap(br.err, "newBackupReader")
			}
			defer br.Close()

			// Only map the predicates which haven't been dropped yet.
			predSet := manifest.getPredsInGroup(gid)
			for p := range predSet {
				if _, ok := dropAttr[p]; ok {
					delete(predSet, p)
				}
			}
			localDropNs := make(map[uint64]struct{})
			for ns := range dropNs {
				localDropNs[ns] = struct{}{}
			}
			in := &loadBackupInput{
				preds:     predSet,
				dropNs:    localDropNs,
				version:   manifest.Version,

View on GitHub (pinned to 759e242be6)

Solutions

  1. Check the wrapped cause: 'not found' means the group's backup file is missing — verify the backup completed fully (all group files present at manifest.Path).
  2. Confirm the encryption key (keys.EncKey) matches the one used when the backup was created.
  3. Verify the manifest's Compression codec is supported by this Dgraph version (upgrade if the backup is newer).
  4. Re-list/re-validate the manifest objects and re-run; if the backup is incomplete, take a new backup.
Defensive patterns

Strategy: validation

Validate before calling

// ensure every group's backup file exists at the manifest path before restore
for _, gid := range groupIds {
    if !objectExists(manifest.Path, backupName(ts, gid)) {
        return fmt.Errorf("backup file for group %d missing", gid)
    }
}

Try / catch

br := readerFrom(h, file).WithEncryption(keys.EncKey).WithCompression(manifest.Compression)
if br.err != nil {
    // wrapped by RunMapper as "newBackupReader"
    return fmt.Errorf("cannot open group backup (check completeness/encryption key): %w", br.err)
}

Prevention

When it happens

Trigger: The backup object for a given group (gid) at file = manifest.Path/backupName(manifest.ValidReadTs(), gid) does not exist or cannot be opened; the WithEncryption key is wrong for this backup; the reader cannot be set up with the manifest's compression codec.

Common situations: Partial or incomplete backup where one group's file is missing; object deleted or lifecycle-ruled away in the store; restoring with the wrong encryption key for that backup generation; backup written with a compression codec unsupported by the current binary.

Related errors


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