aimrocks
aimrocks copied to clipboard
[FEATURE] support BackupEngine
would be great to be able to create a backup from python code
WDYT ?
aimrocks
implements BackupEngine
, however, the feature is not tested well.
Consider you have db
instance of aimrocks.DB
.
To backup:
backup = rocksdb.BackupEngine("test.db/backups")
backup.create_backup(db, flush_before_backup=True)
To restore:
backup = rocksdb.BackupEngine("test.db/backups")
backup.restore_latest_backup("test.db", "test.db") # the second one is wal directory
You can browse the code for the details: https://github.com/aimhubio/aimrocks/blob/db068474a693a90f209a81d97337864b5a6e1513/src/aimrocks/lib_rocksdb.pyx#L2454-L2465
thank for your answer
I just tried and restore_backup do not return anything
import aimrocks
rocks_db = aimrocks.DB("/tmp/example_db", aimrocks.Options())
rocks_db.put(b'1', b"toto", disable_wal=True)
backup = aimrocks.BackupEngine("test.db/backups")
backup.create_backup(rocks_db, flush_before_backup=True)
del rocks_db
backup = aimrocks.BackupEngine("test.db/backups")
rocks_db = backup.restore_latest_backup("test.db", "test.db")
print(rocks_db.get(b'1'))
give
AttributeError: 'NoneType' object has no attribute 'get'