Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python Rocksdb
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
Python Rocksdb
Commits
b5743e85
Commit
b5743e85
authored
11 years ago
by
hofmockel
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation for backup engine
parent
f16daf0a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/api/backup.rst
+68
-0
68 additions, 0 deletions
docs/api/backup.rst
docs/api/index.rst
+1
-0
1 addition, 0 deletions
docs/api/index.rst
docs/tutorial/index.rst
+29
-0
29 additions, 0 deletions
docs/tutorial/index.rst
with
98 additions
and
0 deletions
docs/api/backup.rst
0 → 100644
+
68
−
0
View file @
b5743e85
Backup and Restore
******************
BackupEngine
============
.. py:class:: rocksdb.BackupEngine
.. py:method:: __init__(backup_dir)
Creates a object to manage backup of a single database.
:param unicode backup_dir: Where to keep the backup files.
Has to be different than db.db_name.
For example db.db_name + '/backups'.
.. py:method:: create_backup(db, flush_before_backup=False)
Triggers the creation of a backup.
:param db: Database object to backup.
:type db: :py:class:`rocksdb.DB`
:param bool flush_before_backup: If ``True`` the current memtable is flushed.
.. py:method:: restore_backup(backup_id, db_dir, wal_dir)
Restores the backup from the given id.
:param int backup_id: id of the backup to restore.
:param unicode db_dir: Target directory to restore backup.
:param unicode wal_dir: Target directory to restore backuped WAL files.
.. py:method:: restore_latest_backup(db_dir, wal_dir)
Restores the latest backup.
:param unicode db_dir: see :py:meth:`restore_backup`
:param unicode wal_dir: see :py:meth:`restore_backup`
.. py:method:: stop_backup()
Can be called from another thread to stop the current backup process.
.. py:method:: purge_old_backups(num_backups_to_keep)
Deletes all backups (oldest first) until "num_backups_to_keep" are left.
:param int num_backups_to_keep: Number of backupfiles to keep.
.. py:method:: delete_backup(backup_id)
:param int backup_id: Delete the backup with the given id.
.. py:method:: get_backup_info()
Returns infomration about all backups.
It returns a list of dict's where each dict as the following keys.
``backup_id``
(int): id of this backup.
``timestamp``
(int): Seconds since epoch, when the backup was created.
``size``
(int): Size in bytes of the backup.
This diff is collapsed.
Click to expand it.
docs/api/index.rst
+
1
−
0
View file @
b5743e85
...
...
@@ -8,3 +8,4 @@ Python driver for RocksDB
Options <options>
Database <database>
Interfaces <interfaces>
Backup <backup>
This diff is collapsed.
Click to expand it.
docs/tutorial/index.rst
+
29
−
0
View file @
b5743e85
...
...
@@ -241,3 +241,32 @@ So always the first 5 bytes are used as the prefix ::
# prints {b'00002.z': b'z', b'00002.y': b'y', b'00002.x': b'x'}
print dict(it)
Backup And Restore
==================
Backup and Restore is done with a separate :py:class:`rocksdb.BackupEngine` object.
A backup can only be created on a living database object ::
import rocksdb
db = rocksdb.DB("test.db", rocksdb.Options(create_if_missing=True))
db.put(b'a', b'v1')
db.put(b'b', b'v2')
db.put(b'c', b'v3')
Backup is created like this.
You can choose any path for the backup destination except the db path itself.
If ``flush_before_backup`` is ``True`` the current memtable is flushed to disk
before backup ::
backup = rocksdb.BackupEngine("test.db/backups")
backup.create_backup(db, flush_before_backup=True)
Restore is done like this.
The two arguments are the db_dir and wal_dir, which are mostly the same ::
backup = rocksdb.BackupEngine("test.db/backups")
backup.restore_latest_backup("test.db", "test.db")
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment