...
Code Block |
---|
language | py |
---|
title | verify_leveldb.py |
---|
collapse | true |
---|
|
#!/usr/bin/python
import sys
import leveldb
from datetime import datetime
import subprocess
if (len(sys.argv) != 2) :
print 'Usage:'
print 'python verify_leveldb.py /path/to/leveldb/cache/'
sys.exit(1)
dbpath = sys.argv[1]
try:
startTime = datetime.now()
print sys.argv[0], ": Inspecting db: ", dbpath
db = leveldb.LevelDB(dbpath, create_if_missing=False, paranoid_checks=True)
it = db.RangeIter(None, None, True, True, True)
records = 0;
for key, value in it:
records = records + 1
print sys.argv[0], ": Backup verfiication successful!"
print sys.argv[0], ": Total records: ", records
print sys.argv[0], ": Time taken:", datetime.now() - startTime
except:
print sys.argv[0], ": Backup verfication failed!"
print sys.argv[0], ": Unexpected error:", sys.exc_info()[0]
raise
exit(1)
# Rename ldb files to sst (Python API uses ldb extension, whereas infinispan expects sst)
script = 'for f in ' + dbpath + '/*.ldb; do mv $f "${f%.ldb}.sst"; done'
subprocess.call(['/bin/bash', '-c', script]) |
Anchor |
---|
| Repairingrepair-Corrup-LevelDBleveldbRepairing |
---|
| repair-Corrup-LevelDBleveldb |
---|
|
Repairing Corrupt LevelDBÂ
...