Yes, if I understand what you are saying right I think that would definitely work for what I want to do.
To re-cap, since there is still some confusion, what I want to do is keep a replica of the DB files somewhere else and frequently sync this replica by applying a diff (basically an online backup). ActiveMQ was trying to do a similar thing I think but they have to do all kinds of hijinks to get a consistent snapshot of the files (
https://github.com/fusesource/fuse-extra/tree/master/fusemq-leveldb), so this is a relatively common need, perhaps. BDB JE also supports some functionality to pause compaction for this very reason.
One detail of my case is I actually don't care if i block writes for a few seconds while the backup occurs as long as the backup is incremental. But for most people they would probably want a low-latency snapshot capability.
A filesystem-level snapshot would work, but adds a lot of other downsides. Since leveldb is append only snapshots at the application level should be really straight-forward.
So Dhruba, to flesh out what you are saying, I think to do incremental backups using your functionality I would do the following:
1. Pause new writes
2. List the current .sst and .log files and their exact lengths, this comprises an exact point-in-time snapshot of the data
3. Compute the diff from the last backup (e.g. new files and newly appended data on existing files)
4. Apply this diff to the backup location, grabbing the data either from the main data directory or from the archival directory if the files have been deleted).
This would also work for me, though it seems a bit more complex then just pausing compaction for 30 seconds while the backup occurs. Do you have a fork where you are doing this I would love to check it out.
Also, any hope of any of these things getting back into mainline?
-Jay