Search code examples
lmdb

How to I dump a lmdb database for backup purposes?


I want to dump a LMDB database. I tried the mdb_dump command, but it's not obvious what combination of options to use:

mdb_dump -s $PWD/foobar-00.lmdb >foobar-00.lmdb.dump

usage: mdb_dump [-V] [-f output] [-l] [-n] [-p] [-a|-s subdb] dbpath


Solution

  • Here's the answer: Give a LMDB database at /path/to/foobar-00.lmdb, dump it as follows

    mdb_dump -n /path/to/foobar-00.lmdb>foobar-00.lmdb.dump

    To restore,

    cd /path/to; mdb_load -n -f foobar-00.lmdb.dump

    These utilities are in package lmdb-utils (for Ubuntu).