From 6daf0aa3655b7270de74f4aa1027f97b259ff284 Mon Sep 17 00:00:00 2001 From: JP Hwang Date: Wed, 9 Oct 2024 22:25:51 +0100 Subject: [PATCH 1/2] Partial update for backup cancel --- _includes/code/howto/configure.backups.py | 138 ++++++++++--------- developers/weaviate/configuration/backups.md | 23 ++++ 2 files changed, 96 insertions(+), 65 deletions(-) diff --git a/_includes/code/howto/configure.backups.py b/_includes/code/howto/configure.backups.py index 3049de4a74..196b369d6e 100644 --- a/_includes/code/howto/configure.backups.py +++ b/_includes/code/howto/configure.backups.py @@ -4,93 +4,101 @@ # ===== INSTANTIATION-COMMON ===== # ================================ -# START CreateBackup # START RestoreBackup # START StatusCreateBackup # START StatusRestoreBackup +# START CreateBackup # START RestoreBackup # START StatusCreateBackup # START StatusRestoreBackup # START CancelBackup import weaviate client = weaviate.connect_to_local() -try: - # END CreateBackup # END RestoreBackup # END StatusCreateBackup # END StatusRestoreBackup +# END CreateBackup # END RestoreBackup # END StatusCreateBackup # END StatusRestoreBackup # END CancelBackup - # Create the collections, whether they exist or not - client.collections.delete(["Article", "Publication"]) - articles = client.collections.create(name="Article") - publications = client.collections.create(name="Publication") +# Create the collections, whether they exist or not +client.collections.delete(["Article", "Publication"]) +articles = client.collections.create(name="Article") +publications = client.collections.create(name="Publication") - articles.data.insert(properties={"title": "Dummy"}) - publications.data.insert(properties={"title": "Dummy"}) +articles.data.insert(properties={"title": "Dummy"}) +publications.data.insert(properties={"title": "Dummy"}) - # START CreateBackup - result = client.backup.create( - backup_id="my-very-first-backup", - backend="filesystem", - include_collections=["Article", "Publication"], - wait_for_completion=True, - ) +# START CreateBackup +result = client.backup.create( + backup_id="my-very-first-backup", + backend="filesystem", + include_collections=["Article", "Publication"], + wait_for_completion=True, +) - print(result) - # END CreateBackup +print(result) +# END CreateBackup - # Test - assert result.status == "SUCCESS" +# Test +assert result.status == "SUCCESS" - # ============================================== - # ===== Check status while creating backup ===== - # ============================================== +# ============================================== +# ===== Check status while creating backup ===== +# ============================================== - # START StatusCreateBackup - result = client.backup.get_create_status( - backup_id="my-very-first-backup", - backend="filesystem", - ) +# START StatusCreateBackup +result = client.backup.get_create_status( + backup_id="my-very-first-backup", + backend="filesystem", +) - print(result) - # END StatusCreateBackup +print(result) +# END StatusCreateBackup - # Test - assert result.status == "SUCCESS" +# Test +assert result.status == "SUCCESS" - # ========================== - # ===== Restore backup ===== - # ========================== +# ========================== +# ===== Restore backup ===== +# ========================== - client.collections.delete("Publication") +client.collections.delete("Publication") - # START RestoreBackup - result = client.backup.restore( - backup_id="my-very-first-backup", - backend="filesystem", - exclude_collections="Article", - wait_for_completion=True, - ) +# START RestoreBackup +result = client.backup.restore( + backup_id="my-very-first-backup", + backend="filesystem", + exclude_collections="Article", + wait_for_completion=True, +) - print(result) - # END RestoreBackup +print(result) +# END RestoreBackup - # Test - assert result.status == "SUCCESS" +# Test +assert result.status == "SUCCESS" - # ============================================== - # ===== Check status while restoring backup ===== - # ============================================== +# ============================================== +# ===== Check status while restoring backup ===== +# ============================================== - # START StatusRestoreBackup - result = client.backup.get_restore_status( - backup_id="my-very-first-backup", - backend="filesystem", - ) +# START StatusRestoreBackup +result = client.backup.get_restore_status( + backup_id="my-very-first-backup", + backend="filesystem", +) - print(result) - # END StatusRestoreBackup +print(result) +# END StatusRestoreBackup - # Test - assert result.status == "SUCCESS" +# Test +assert result.status == "SUCCESS" - # Clean up - client.collections.delete(["Article", "Publication"]) +# Clean up +client.collections.delete(["Article", "Publication"]) -# START-ANY +# ============================================== +# ===== Cancel ongoing backup ===== +# ============================================== -finally: - client.close() -# END-ANY +# START CancelBackup +result = client.backup.cancel_backup( + backup_id="my-very-first-backup", + backend="filesystem", +) + +print(result) +# END CancelBackup + +client.close() diff --git a/developers/weaviate/configuration/backups.md b/developers/weaviate/configuration/backups.md index 8b3ff79108..dfc0aee570 100644 --- a/developers/weaviate/configuration/backups.md +++ b/developers/weaviate/configuration/backups.md @@ -380,6 +380,29 @@ The response contains a `"status"` field. If the status is `SUCCESS`, the backup +### Cancel Backup + +An ongoing backup can be cancelled at any time. The backup process will be stopped, and the backup will be marked as `CANCELLED`. + + + + + + + + ```ts + // Coming soon + ``` + + + + +This operation is particularly useful if you have started a backup by accident, or if you would like to stop a backup that is taking too long. ### Restore Backup You can restore any backup to any machine as long as the name and number of nodes between source and target are identical. The backup does not need to be created on the same instance. Once a backup backend is configured, you can restore a backup with a single HTTP request. From 7136ff9d0b32ed35dde9272962225541f2d420f9 Mon Sep 17 00:00:00 2001 From: Dirk Kulawiak Date: Wed, 16 Oct 2024 08:36:15 +0200 Subject: [PATCH 2/2] Fix python example for backup cancel --- _includes/code/howto/configure.backups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/code/howto/configure.backups.py b/_includes/code/howto/configure.backups.py index 196b369d6e..50f1b0db4a 100644 --- a/_includes/code/howto/configure.backups.py +++ b/_includes/code/howto/configure.backups.py @@ -93,7 +93,7 @@ # ============================================== # START CancelBackup -result = client.backup.cancel_backup( +result = client.backup.cancel( backup_id="my-very-first-backup", backend="filesystem", )