How to backup badgerdb?

https://dgraph.io/docs/badger/get-started/#database-backup

Badger v0.9 provides a CLI tool badger , which can do offline backup/restore. Make sure you have $GOPATH/bin in your PATH to use this tool.

Do the offline backup/restore CLI tool only provided by badger v0.9? I use badger v3, but I can’t find the CLI tool. If I want to backup badger v3, the only way is to use public API methods DB.Backup() and DB.Load() ?

1 Like

The CLI tool is in the repo here and is still around: badger/badger/cmd at master · dgraph-io/badger · GitHub

The CLI backup tool just executes db.Backup()/Load()

But db.Backup() is a small wrapper around a badgerdb Stream with a known format for Load() to use, so you could implement whatever you want on your own Stream and have it make more sense for your application maybe.

1 Like

ok, I see, thanks. One another question, when I use the backup API or restore API, must I stop the front writing ops, that is to say, I need stop the business to call backup or restore API?

for backup, no - for load, yes. Check the docs, details are there.

1 Like

OK, thanks