From 8884fcd66bf44342d0c8048692c379ba2252be76 Mon Sep 17 00:00:00 2001 From: wayblink Date: Thu, 7 Nov 2024 18:20:07 +0800 Subject: [PATCH] Update docs Signed-off-by: wayblink --- README.md | 201 ++++++-------------------------- docs/user_guide/api_demo.md | 74 ++++++++++++ docs/user_guide/e2e_demo_cli.md | 69 +++++++++++ docs/user_guide/figs/log.png | Bin 0 -> 1811 bytes 4 files changed, 177 insertions(+), 167 deletions(-) create mode 100644 docs/user_guide/api_demo.md create mode 100644 docs/user_guide/e2e_demo_cli.md create mode 100644 docs/user_guide/figs/log.png diff --git a/README.md b/README.md index 6fd1d8e..2c1e5fa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,11 @@ # Milvus-backup +
+ license + license +
+ + +milvus--backup-logo Milvus-Backup is a tool that allows users to backup and restore Milvus data. This tool can be utilized either through the command line or an API server. @@ -8,145 +15,30 @@ The Milvus-backup process has negligible impact on the performance of Milvus. Mi * Download binary from [release page](https://github.com/zilliztech/milvus-backup/releases). Usually the latest is recommended. - For Mac: * Use [homebrew](https://brew.sh/) to install ```shell brew install zilliztech/tap/milvus-backup ``` -## Config +## Get started + +Milvus-backup provides command line and API server for usage. + +### Config In order to use Milvus-Backup, access to Milvus proxy and Minio cluster is required. Configuration settings related to this access can be edited in `backup.yaml`. > [!NOTE] > > Please ensure that the configuration settings for Minio are accurate. There may be variations in the default value of Minio's configuration depending on how Milvus is deployed, either by docker-compose or k8s. -> -> Please be advised that it is not possible to backup data to a local path. Backup data is stored in Minio or another object storage solution used by your Milvus instance. > |field|docker-compose |helm| > |---|---|---| > |bucketName|a-bucket|milvus-bucket| > |rootPath|files|file| -## Development +### Command Line -### Build - -``` -go get -go build -``` - -Will generate an executable binary `milvus-backup` in the project directory. - -### Test - -Developers can also test it using an IDE. `core/backup_context_test.go` contains test demos for all main interfaces. Alternatively, you can test it using the command line interface: - -```shell -cd core -go test -v -test.run TestCreateBackup -``` - -## API server - -To start the RESTAPI server, use the following command after building: - -```shell -./milvus-backup server -``` - -The server will listen on port 8080 by default. However, you can change it by using the `-p` parameter as shown below: - -```shell -./milvus-backup server -p 443 -``` - -### swagger UI - -We offer access to our Swagger UI, which displays comprehensive information for our APIs. To view it, simply go to - -``` -http://localhost:8080/api/v1/docs/index.html -``` - -### API Reference - -### `/create` - -Creates a backup for the cluster. Data of selected collections will be copied to a backup directory. You can specify a group of collection names to backup, or if left empty (by default), it will backup all collections. - -``` -curl --location --request POST 'http://localhost:8080/api/v1/create' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "async": true, - "backup_name": "test_backup", - "collection_names": [ - "test_collection1","test_collection2" - ] -}' -``` - -### `/list` - -Lists all backups that exist in the `backup` directory in MinIO. - -``` -curl --location --request GET 'http://localhost:8080/api/v1/list' \ ---header 'Content-Type: application/json' -``` - -### `/get_backup` - -Retrieves a backup by name. - -``` -curl --location --request GET 'http://localhost:8080/api/v1/get_backup?backup_name=test_backup' \ ---header 'Content-Type: application/json' -``` - -### `/delete` - -Deletes a backup by name. - -``` -curl --location --request DELETE 'http://localhost:8080/api/v1/delete?backup_name=test_api' \ ---header 'Content-Type: application/json' -``` - -### `/restore` - -Restores a backup by name. It recreates the collections in the cluster and recovers the data through bulk insert. For more details about bulk insert, please refer to: -https://milvus.io/docs/bulk_insert.md - -Bulk inserts will be done by partition. Currently, concurrent bulk inserts are not supported. - -``` -curl --location --request POST 'http://localhost:8080/api/v1/restore' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "async": true, - "collection_names": [ - "test_collection1" - ], - "collection_suffix": "_bak", - "backup_name":"test_backup" -}' -``` - -### `/get_restore` - -This is only available in the REST API. Retrieves restore task information by ID. We support async restore in the REST API, and you can use this method to get information on the restore execution status. - -``` -curl --location --request GET 'http://localhost:8080/api/v1/get_restore?id=test_restore_id' \ ---header 'Content-Type: application/json' -``` - -## Command Line - -Milvus-backup establish CLI based on cobra. Use the following command to see the usage. +Milvus-backup establish CLI based on cobra. Use the following command to see all the usage. ``` milvus-backup is a backup&restore tool for milvus. @@ -172,75 +64,50 @@ Flags: Use "milvus-backup [command] --help" for more information about a command. ``` -## Demo +Here is a [demo](docs/user_guide/e2e_demo_cli.md) for a complete backup and restore process. -To try this demo, you should have a functional Milvus server installed and have pymilvus library installed. +### API Server -Step 0: Check the connections - -First of all, we can use `check` command to check whether connections to milvus and storage is normal: +To start the RESTAPI server, use the following command after building: -``` -./milvus-backup check +```shell +./milvus-backup server ``` -normal output: +The server will listen on port 8080 by default. However, you can change it by using the `-p` parameter as shown below: ```shell -Succeed to connect to milvus and storage. -Milvus version: v2.3 -Storage: -milvus-bucket: a-bucket -milvus-rootpath: files -backup-bucket: a-bucket -backup-rootpath: backup +./milvus-backup server -p 443 ``` -Step 1: Prepare the Data +We offer a [demo](docs/user_guide/api_demo.md) of the key APIs; however, please refer to the Swagger UI for the most up-to-date usage details, as the demo may occasionally become outdated. -Create a collection in Milvus called `hello_milvus` and insert some data using the following command: - -``` -python example/prepare_data.py -``` - -Step 2: Create a Backup +### swagger UI -Use the following command to create a backup of the `hello_milvus` collection: +We offer access to our Swagger UI, which displays comprehensive information for our APIs. To view it, simply go to ``` -./milvus-backup create -n my_backup +http://localhost:8080/api/v1/docs/index.html ``` -Step 3: Restore the Backup - -Restore the backup using the following command: - -``` -./milvus-backup restore -n my_backup -s _recover -``` -This will create a new collection called `hello_milvus_recover` which contains the data from the original collection. +## Development -**Note:** if you want to restore index as well, add `--restore_index`, like this: +### Build -``` -./milvus-backup restore --restore_index -n my_backup -s _recover -``` +For developers, Milvus-backup is easy to contribute to. -This will help you restore data and index at the same time. If you don't add this flag, you need to restore index manually. +Execute `make all` will generate an executable binary `milvus-backup` in the `{project_path}/bin` directory. -Step 4: Verify the Restored Data +### Test -Create an index on the restored collection using the following command: +Developers can also test it using an IDE. `core/backup_context_test.go` contains test demos for all main interfaces. Alternatively, you can test it using the command line interface: +```shell +cd core +go test -v -test.run TestCreateBackup ``` -python example/verify_data.py -``` - -This will perform a search on the `hello_milvus_recover` collection and verify that the restored data is correct. -That's it! You have successfully backed up and restored your Milvus collection. ## License milvus-backup is licensed under the Apache License, Version 2.0. diff --git a/docs/user_guide/api_demo.md b/docs/user_guide/api_demo.md new file mode 100644 index 0000000..ffa6501 --- /dev/null +++ b/docs/user_guide/api_demo.md @@ -0,0 +1,74 @@ +# API Demos + +### `/create` + +Creates a backup for the cluster. Data of selected collections will be copied to a backup directory. You can specify a group of collection names to backup, or if left empty (by default), it will backup all collections. + +``` +curl --location --request POST 'http://localhost:8080/api/v1/create' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "async": true, + "backup_name": "test_backup", + "collection_names": [ + "test_collection1","test_collection2" + ] +}' +``` + +### `/list` + +Lists all backups that exist in the `backup` directory in MinIO. + +``` +curl --location --request GET 'http://localhost:8080/api/v1/list' \ +--header 'Content-Type: application/json' +``` + +### `/get_backup` + +Retrieves a backup by name. + +``` +curl --location --request GET 'http://localhost:8080/api/v1/get_backup?backup_name=test_backup' \ +--header 'Content-Type: application/json' +``` + +### `/delete` + +Deletes a backup by name. + +``` +curl --location --request DELETE 'http://localhost:8080/api/v1/delete?backup_name=test_api' \ +--header 'Content-Type: application/json' +``` + +### `/restore` + +Restores a backup by name. It recreates the collections in the cluster and recovers the data through bulk insert. For more details about bulk insert, please refer to: +https://milvus.io/docs/bulk_insert.md + +Bulk inserts will be done by partition. Currently, concurrent bulk inserts are not supported. + +``` +curl --location --request POST 'http://localhost:8080/api/v1/restore' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "async": true, + "collection_names": [ + "test_collection1" + ], + "collection_suffix": "_bak", + "backup_name":"test_backup" +}' +``` + +### `/get_restore` + +This is only available in the REST API. Retrieves restore task information by ID. We support async restore in the REST API, and you can use this method to get information on the restore execution status. + +``` +curl --location --request GET 'http://localhost:8080/api/v1/get_restore?id=test_restore_id' \ +--header 'Content-Type: application/json' +``` + diff --git a/docs/user_guide/e2e_demo_cli.md b/docs/user_guide/e2e_demo_cli.md new file mode 100644 index 0000000..752c61e --- /dev/null +++ b/docs/user_guide/e2e_demo_cli.md @@ -0,0 +1,69 @@ +# E2e Demo + +To try this demo, you should have a functional Milvus server installed and have pymilvus library installed. + +Step 0: Check the connections + +First of all, we can use `check` command to check whether connections to milvus and storage is normal: + +``` +./milvus-backup check +``` + +normal output: + +```shell +Succeed to connect to milvus and storage. +Milvus version: v2.4.0 +Storage: +milvus-bucket: a-bucket +milvus-rootpath: files +backup-bucket: a-bucket +backup-rootpath: backup +``` + +Step 1: Prepare the Data + +Create a collection in Milvus called `hello_milvus` and insert some data using the following command: + +``` +python example/prepare_data.py +``` + +Step 2: Create a Backup + +Use the following command to create a backup of the `hello_milvus` collection: + +``` +./milvus-backup create -n my_backup +``` + +Step 3: Restore the Backup + +Restore the backup using the following command: + +``` +./milvus-backup restore -n my_backup -s _recover +``` + +This will create a new collection called `hello_milvus_recover` which contains the data from the original collection. + +**Note:** if you want to restore index as well, add `--restore_index`, like this: + +``` +./milvus-backup restore --restore_index -n my_backup -s _recover +``` + +This will help you restore data and index at the same time. If you don't add this flag, you need to restore index manually. + +Step 4: Verify the Restored Data + +Create an index on the restored collection using the following command: + +``` +python example/verify_data.py +``` + +This will perform a search on the `hello_milvus_recover` collection and verify that the restored data is correct. + +That's it! You have successfully backed up and restored your Milvus collection. diff --git a/docs/user_guide/figs/log.png b/docs/user_guide/figs/log.png new file mode 100644 index 0000000000000000000000000000000000000000..552017b8e8518a636ae7f89f96e6961ccd66e375 GIT binary patch literal 1811 zcmV+u2kiKXP)!=Q-a@?lKnPCfh$o}p}-Y|dF`4aJz9MxpLI`GzSpLR z{)$ux`e5jOHym8a?y6L%hh3Dr*_6^ldyVY1Jj7Kmw#FPA0iyR%paBz^_H47nM^#aiZdD&OB5bUX0VCeQQ z3-;4f4U zS&O@IMsgpRChkMC#u{#GnkFEnttm;`j!X+)e%3;_F_L!Y6w`KiT2lLOno)2JbQ@ja zom1p!TJlk6k{oSGN^P!Wh&R|c&rdPX*LmKVRMPz?WgH9Nk~G$^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