...
- Check leveldb cache store directory from the backup using a leveldb client.
- Verify the leveldb opens.
- Verify by iterating through the keys. (To expose any corruption)
Based on the flow of the background compaction process in the leveldb implementation ([1] and [2]), the manifest file is updated at the end of compaction, which is followed by the deletion of obsolete files. To verify successful backups, we can begin the backup with copying the manifest file followed by the rest of the files. And, at the end of the backup, the backed up manifest file can be compared with the current manifest. An unchanged manifest can be considered as a successful backup, and vice versa.
[1] https://github.com/google/leveldb/blob/master/db/db_impl.cc#L655
[2] https://github.com/google/leveldb/blob/master/db/version_set.cc#L811
...
Repairing Corrupt LevelDB
The below script can be used to repair corrupt leveldb cache:
Code Block | ||
---|---|---|
| ||
#!/usr/bin/python
import leveldb
import sys
import os
if (len(sys.argv) != 2) :
print 'Usage:'
print 'python repair.py /path/to/leveldb/cache'
sys.exit(1)
path = sys.argv[1]
if not os.path.isdir(path) :
print "Directory %s does not exist!" % path
sys.exit()
leveldb.RepairDB(path) |