Skip to content

Commit af49288

Browse files
Merge pull request #152 from weaviate/djanicek/incremental-backups
incremental backups support
2 parents dd41083 + fa2300d commit af49288

7 files changed

Lines changed: 33 additions & 2 deletions

File tree

.claude/skills/operating-weaviate-cli/SKILL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,14 @@ See [references/tenants.md](references/tenants.md).
209209
```bash
210210
weaviate-cli create backup --backend s3 --backup_id my-backup --wait --json
211211
weaviate-cli create backup --backend s3 --backup_id my-backup --include "Movies,Books" --wait --json
212+
weaviate-cli create backup --backend s3 --backup_id my-incremental --incremental_base_backup_id my-backup --json
212213
weaviate-cli get backup --backend s3 --backup_id my-backup --json
213214
weaviate-cli get backup --backend s3 --backup_id my-backup --restore --json
214215
weaviate-cli restore backup --backend s3 --backup_id my-backup --wait --json
215216
weaviate-cli cancel backup --backend s3 --backup_id my-backup --json
216217
```
217218

218-
Backends: `s3`, `gcs`, `filesystem`. Options: `--include`, `--exclude`, `--wait`, `--cpu_for_backup N`, `--override-alias`
219+
Backends: `s3`, `gcs`, `filesystem`. Options: `--include`, `--exclude`, `--wait`, `--cpu_for_backup N`, `--override-alias`, `--incremental_base_backup_id`
219220

220221
See [references/backups.md](references/backups.md).
221222

.claude/skills/operating-weaviate-cli/references/backups.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Create, inspect, restore, and cancel Weaviate backups.
77
weaviate-cli create backup --backend s3 --backup_id my-backup --wait --json
88
weaviate-cli create backup --backend s3 --backup_id my-backup --include "Movies,Books" --wait --json
99
weaviate-cli create backup --backend gcs --backup_id my-backup --exclude "TempData" --cpu_for_backup 60 --json
10+
weaviate-cli create backup --backend s3 --backup_id my-incremental-backup --incremental_base_backup_id my-backup --json
1011
```
1112

1213
## Check Backup Status
@@ -40,6 +41,7 @@ weaviate-cli cancel backup --backend s3 --backup_id my-backup --json
4041
- `--exclude` -- Comma-separated collections to exclude
4142
- `--wait` -- Wait for completion
4243
- `--cpu_for_backup` -- CPU percentage for backup (default: 40)
44+
- `--incremental_base_backup_id` -- Backup ID of a previous backup to create an incremental backup from. Requires Weaviate 1.34+.
4345

4446
**Restore:**
4547
- `--backend`, `--backup_id` -- Same as create
@@ -59,3 +61,4 @@ weaviate-cli cancel backup --backend s3 --backup_id my-backup --json
5961
- Without `--wait`, the command returns immediately and you must poll with `get backup`
6062
- `--cpu_for_backup` controls backup speed vs. resource consumption tradeoff
6163
- `--include` and `--exclude` are mutually exclusive
64+
- Incremental backups require Weaviate 1.34+ and can only include collections that were part of the base backup

weaviate_cli/commands/create.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,25 @@ def create_tenants_cli(
406406
default=CreateBackupDefaults.cpu_for_backup,
407407
help="The percentage of CPU to use for the backup (default: 40). The larger, the faster it will occur, but it will also consume more memory.",
408408
)
409+
@click.option(
410+
"--incremental_base_backup_id",
411+
default=CreateBackupDefaults.incremental_base_backup_id,
412+
help="The backup_id of the previous backup to create an incremental backup from.",
413+
)
409414
@click.option(
410415
"--json", "json_output", is_flag=True, default=False, help="Output in JSON format."
411416
)
412417
@click.pass_context
413418
def create_backup_cli(
414-
ctx, backend, backup_id, include, exclude, wait, cpu_for_backup, json_output
419+
ctx,
420+
backend,
421+
backup_id,
422+
include,
423+
exclude,
424+
wait,
425+
cpu_for_backup,
426+
incremental_base_backup_id,
427+
json_output,
415428
):
416429
"""Create a backup in Weaviate."""
417430

@@ -426,6 +439,7 @@ def create_backup_cli(
426439
exclude=exclude,
427440
wait=wait,
428441
cpu_for_backup=cpu_for_backup,
442+
incremental_base_backup_id=incremental_base_backup_id,
429443
json_output=json_output,
430444
)
431445
except Exception as e:

weaviate_cli/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class CreateTenantsDefaults:
103103
class CreateBackupDefaults:
104104
backend: str = "s3"
105105
backup_id: str = "test-backup"
106+
incremental_base_backup_id: Optional[str] = None
106107
include: Optional[str] = None
107108
exclude: Optional[str] = None
108109
wait: bool = False

weaviate_cli/managers/backup_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def create_backup(
2525
wait: bool = CreateBackupDefaults.wait,
2626
cpu_for_backup: int = CreateBackupDefaults.cpu_for_backup,
2727
json_output: bool = False,
28+
incremental_base_backup_id: Optional[
29+
str
30+
] = CreateBackupDefaults.incremental_base_backup_id,
2831
) -> None:
2932

3033
version = semver.Version.parse(self.client.get_meta()["version"])
@@ -44,6 +47,7 @@ def create_backup(
4447
result = self.client.backup.create(
4548
backup_id=backup_id,
4649
backend=backend,
50+
incremental_base_backup_id=incremental_base_backup_id,
4751
include_collections=include.split(",") if include else None,
4852
exclude_collections=exclude.split(",") if exclude else None,
4953
wait_for_completion=wait,

weaviate_cli/managers/collection_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ def create_collection(
524524
wvc.Property(name="releaseDate", data_type=wvc.DataType.DATE),
525525
wvc.Property(name="revenue", data_type=wvc.DataType.NUMBER),
526526
wvc.Property(name="status", data_type=wvc.DataType.TEXT),
527+
wvc.Property(name="coverImage", data_type=wvc.DataType.BLOB),
527528
]
528529

529530
rds_map = {

weaviate_cli/managers/data_manager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
import importlib.resources as resources
23
import json
34
import math
@@ -205,6 +206,9 @@ def generate_movie_object(is_update: bool = False, seed: Optional[int] = None) -
205206
# Generate a movie title with proper capitalization
206207
title = fake.catch_phrase()
207208

209+
# Generate blob data to simulate an image
210+
cover_image = base64.b64encode(fake.binary(10)).decode("utf-8")
211+
208212
# Prefix for update operations
209213
prefix = "updated-" if is_update else ""
210214

@@ -224,6 +228,7 @@ def generate_movie_object(is_update: bool = False, seed: Optional[int] = None) -
224228
"status": random.choice(STATUSES),
225229
"spokenLanguages": spoken_languages,
226230
"productionCountries": production_countries,
231+
"coverImage": cover_image,
227232
}
228233

229234

@@ -1128,6 +1133,8 @@ def __update_data(
11281133
obj.properties[property] += 1.0
11291134
elif isinstance(value, datetime):
11301135
obj.properties[property] = value + timedelta(days=1)
1136+
elif isinstance(value, bytes):
1137+
obj.properties[property] = value << 1
11311138

11321139
cl_collection.data.update(
11331140
uuid=obj.uuid,

0 commit comments

Comments
 (0)