Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] support BackupEngine #19

Open
raphaelauv opened this issue Jul 7, 2022 · 2 comments
Open

[FEATURE] support BackupEngine #19

raphaelauv opened this issue Jul 7, 2022 · 2 comments

Comments

@raphaelauv
Copy link
Contributor

would be great to be able to create a backup from python code

WDYT ?

@mahnerak
Copy link
Collaborator

mahnerak commented Jul 7, 2022

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:

cpdef restore_backup(self, backup_id, db_dir, wal_dir):
cdef Status st
cdef backup.BackupID c_backup_id
cdef string c_db_dir
cdef string c_wal_dir
c_backup_id = backup_id
c_db_dir = path_to_string(db_dir)
c_wal_dir = path_to_string(wal_dir)
with nogil:
st = self.engine.RestoreDBFromBackup(

@raphaelauv
Copy link
Contributor Author

raphaelauv commented Aug 19, 2022

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants