Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does LevelDB supports hot backups (or equivalent)?

Currently we are evaluating several key+value data stores, to replace an older isam currently in use by owr main application (for 20 something years!) ...

The problem is that our current isam doesn't support crash recoveries.

So LevelDB seemd Ok to us (also checking BerkleyDB, etc)

But we ran into de question of hot-backups, and, given the fact that LevelDB is a library, and not a server, it is odd to ask for 'hot backup', as it would intuitively imply an external backup process.

Perhaps someone would like to propose options (or known solutions) ?

For example: - Hot backup through an inner thread of the main applicacion ? - Hot backup by merely copying the LevelDB data directory ?

Thanks in advance

like image 664
artejera Avatar asked Oct 17 '12 17:10

artejera


3 Answers

You can do a snapshot iteration through a LevelDB, which is probably the best way to make a hot copy (don't forget to close the iterator).

To backup a LevelDB via the filesystem I have previously used a script that creates hard links to all the .sst files (which are immutable once written), and normal copies of the log (and MANIFEST, CURRENT etc) files, into a backup directory on the same partition. This is fast since the log files are small compared to the .sst files.

The DB must be closed (by the application) while the backup runs, but the time taken will obviously be much less than the time taken to copy the entire DB to a different partition, or upload to S3 etc. This can be done once the DB is re-opened by the application.

like image 135
gub Avatar answered Sep 19 '22 03:09

gub


LMDB is an embedded key value store, but unlike LevelDB it supports multi-process concurrency so you can use an external backup process. The mdb_copy utility will make an atomic hot backup of a database, your app doesn't need to stop or do anything special while the backup runs. http://symas.com/mdb/

like image 35
hyc Avatar answered Sep 19 '22 03:09

hyc


I am coming a bit late to this question, but there are forks of LevelDB that offer good live backup capability, such as HyperLevelDB and RocksDB. Both of these are available as npm modules, i.e. level-hyper and level-rocksdb. For more discussion, see How to backup RocksDB? and HyperDex Question.

like image 26
dejs Avatar answered Sep 21 '22 03:09

dejs