|
| 1 | +Backups |
| 2 | +------- |
| 3 | + |
| 4 | +Hot Backups are near instantaneous consistent snapshots of an entire ArangoDB deployment. |
| 5 | +This includes all databases, collections, indexes, Views, graphs, and users at any given time. |
| 6 | +For more information, refer to `ArangoDB Manual`_. |
| 7 | + |
| 8 | +.. _ArangoDB Manual: https://docs.arangodb.com |
| 9 | + |
| 10 | +**Example:** |
| 11 | + |
| 12 | +.. code-block:: python |
| 13 | +
|
| 14 | + from arangoasync import ArangoClient |
| 15 | + from arangoasync.auth import JwtToken |
| 16 | +
|
| 17 | + # Initialize the client for ArangoDB. |
| 18 | + async with ArangoClient(hosts="http://localhost:8529") as client: |
| 19 | + token = JwtToken.generate_token(LOGIN_SECRET) |
| 20 | +
|
| 21 | + # Connect to "_system" database as root user. |
| 22 | + db = await client.db( |
| 23 | + "_system", auth_method="superuser", token=token, verify=True |
| 24 | + ) |
| 25 | +
|
| 26 | + # Get the backup API wrapper. |
| 27 | + backup = db.backup |
| 28 | +
|
| 29 | + # Create a backup. |
| 30 | + result = await backup.create( |
| 31 | + label="foo", |
| 32 | + allow_inconsistent=True, |
| 33 | + force=False, |
| 34 | + timeout=1000 |
| 35 | + ) |
| 36 | + backup_id = result["id"] |
| 37 | +
|
| 38 | + # Retrieve details on all backups |
| 39 | + backups = await backup.get() |
| 40 | +
|
| 41 | + # Retrieve details on a specific backup. |
| 42 | + details = await backup.get(backup_id=backup_id) |
| 43 | +
|
| 44 | + # Upload a backup to a remote repository. |
| 45 | + result = await backup.upload( |
| 46 | + backup_id=backup_id, |
| 47 | + repository="local://tmp/backups", |
| 48 | + config={"local": {"type": "local"}} |
| 49 | + ) |
| 50 | + upload_id = result["uploadId"] |
| 51 | +
|
| 52 | + # Get status of an upload. |
| 53 | + status = await backup.upload(upload_id=upload_id) |
| 54 | +
|
| 55 | + # Abort an upload. |
| 56 | + await backup.upload(upload_id=upload_id, abort=True) |
| 57 | +
|
| 58 | + # Download a backup from a remote repository. |
| 59 | + result = await backup.download( |
| 60 | + backup_id=backup_id, |
| 61 | + repository="local://tmp/backups", |
| 62 | + config={"local": {"type": "local"}} |
| 63 | + ) |
| 64 | + download_id = result["downloadId"] |
| 65 | +
|
| 66 | + # Get status of an download. |
| 67 | + status = await backup.download(download_id=download_id) |
| 68 | +
|
| 69 | + # Abort an download. |
| 70 | + await backup.download(download_id=download_id, abort=True) |
| 71 | +
|
| 72 | + # Restore from a backup. |
| 73 | + await backup.restore(backup_id) |
| 74 | +
|
| 75 | + # Delete a backup. |
| 76 | + await backup.delete(backup_id) |
| 77 | +
|
| 78 | +See :class:`arangoasync.backup.Backup` for API specification. |
0 commit comments