Start from scratch without exporting to RDF(Badger)

Stream data using Badger

BEFORE ANY ATTEMPT. PLEASE BACKUP YOUR FILES.

Download Badger binary and put it in /usr/local/bin/badger

wget https://github.com/dgraph-io/dgraph/releases/download/v23.0.0/badger-linux-amd64.tar.gz
tar -xzf badger-linux-amd64.tar.gz
mv badger-linux-amd64 /usr/local/bin/badger
badger -h

Commands to use

badger info --dir ./p

This will check the integrity of the data.

Check the part => Abnormalities

Abnormalities:
2 extra files.
0 missing files.
0 empty files.
0 truncated manifests.

What matter is missing and truncated. This will check for corrupted files.
If there is, only luck you can count on.

You can also flat your db before streaming it. This can help with streaming. (OPTIONAL)

badger flatten --dir ./p

Stream your data to a new DB

mkdir p_backup
mv p p_backup

badger stream --dir ./p_backup --out ./p

This will copy your data to a new place.

Now you can delete p(with mv it was deleted already), w, zw and t directories.

rm -fr t w zw

  1. After that start a Zero group and Alpha. This step above you should do for each shard/group.
  2. Stop them all. (otherwise all nodes will be “nodeCount”: 0)
  3. Start the cluster again.
    You should have all nodes intact.

Why would I do this?

With a completely new DB, it avoids file conflicts, bad configs, etc. It’s like starting from scratch, but with the same data as before.

Some other case is when you can’t start your cluster for any reason other than corruption.

1 Like