Skip to content

Commit aec943b

Browse files
authored
Merge pull request #205 from kuzzleio/0.28.1-proposal
Release 0.28.1
2 parents c0cb9da + 5517828 commit aec943b

File tree

6 files changed

+109
-35
lines changed

6 files changed

+109
-35
lines changed

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ $ npm install -g kourou
2727
$ kourou COMMAND
2828
running command...
2929
$ kourou (-v|--version|version)
30-
kourou/0.28.0 darwin-arm64 node-v20.10.0
30+
kourou/0.28.1 darwin-arm64 node-v20.10.0
3131
$ kourou --help [COMMAND]
3232
USAGE
3333
$ kourou COMMAND
@@ -149,6 +149,7 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
149149
* [`kourou es:snapshot:create REPOSITORY NAME`](#kourou-essnapshotcreate-repository-name)
150150
* [`kourou es:snapshot:create-repository REPOSITORY LOCATION`](#kourou-essnapshotcreate-repository-repository-location)
151151
* [`kourou es:snapshot:list REPOSITORY`](#kourou-essnapshotlist-repository)
152+
* [`kourou es:snapshot:restore REPOSITORY NAME`](#kourou-essnapshotrestore-repository-name)
152153
* [`kourou file:decrypt FILE`](#kourou-filedecrypt-file)
153154
* [`kourou file:encrypt FILE`](#kourou-fileencrypt-file)
154155
* [`kourou file:test FILE`](#kourou-filetest-file)
@@ -795,6 +796,23 @@ OPTIONS
795796

796797
_See code: [lib/commands/es/snapshot/list.js](lib/commands/es/snapshot/list.js)_
797798

799+
## `kourou es:snapshot:restore REPOSITORY NAME`
800+
801+
Restore a snapshot repository inside an ES instance
802+
803+
```
804+
USAGE
805+
$ kourou es:snapshot:restore REPOSITORY NAME
806+
807+
ARGUMENTS
808+
REPOSITORY ES repository name
809+
NAME ES snapshot name
810+
811+
OPTIONS
812+
-n, --node=node [default: http://localhost:9200] Elasticsearch server URL
813+
--help show CLI help
814+
```
815+
798816
## `kourou file:decrypt FILE`
799817

800818
Decrypts an encrypted file.

features/Elasticsearch.feature features/Z_Elasticsearch.feature

+35-30
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,7 @@ Feature: Elasticsearch commands
2828
Then I should match stdout with "{"index": "%kuzzle.users", "alias": "@%kuzzle.users"}"
2929

3030
@mappings
31-
Scenario: Insert ES document
32-
Given a collection "nyc-open-data":"green-taxi"
33-
When I run the command "es:indices:insert" with:
34-
| arg | &nyc-open-data.yellow-taxi | |
35-
| flag | --id | kindred |
36-
| flag | --body | {} |
37-
When I run the command "es:indices:get" with args:
38-
| "&nyc-open-data.yellow-taxi" |
39-
| "kindred" |
40-
Then I should match stdout with "kindred"
41-
42-
Scenario: Create a snapshot repository
43-
When I run the command "es:snapshot:create-repository" with:
44-
| arg | backup | |
45-
| arg | /tmp/snapshots | |
46-
| flag | --compress | |
47-
Then I should match stdout with "Success"
48-
49-
Scenario: Dump ES data to a snapshot into a repository
50-
When I run the command "es:snapshot:create" with:
51-
| arg | backup | |
52-
| arg | test-snapshot | |
53-
Then I should match stdout with "Success"
54-
55-
Scenario: List all available snapshot of a repository
56-
When I run the command "es:snapshot:list" with:
57-
| arg | backup | |
58-
Then I should match stdout with "test-snapshot"
59-
6031
Scenario: Dump and restore ES data to a dump folder using the pattern option
61-
Given an index "nyc-open-data"
6232
Given a collection "nyc-open-data":"yellow-taxi"
6333
Then I create the following document:
6434
| _id | "chuon-chuon-kim" |
@@ -82,3 +52,38 @@ Feature: Elasticsearch commands
8252
Given an existing collection "nyc-open-data":"yellow-taxi"
8353
Then I refresh the collection
8454
And I count 3 documents
55+
56+
Scenario: Insert ES document
57+
Given a collection "nyc-open-data":"blue-taxi"
58+
When I run the command "es:indices:insert" with:
59+
| arg | &nyc-open-data.blue-taxi | |
60+
| flag | --id | kindred |
61+
| flag | --body | {} |
62+
When I run the command "es:indices:get" with args:
63+
| "&nyc-open-data.blue-taxi" |
64+
| "kindred" |
65+
Then I should match stdout with "kindred"
66+
67+
Scenario: Create a snapshot repository
68+
When I run the command "es:snapshot:create-repository" with:
69+
| arg | backup | |
70+
| arg | /tmp/snapshots | |
71+
| flag | --compress | |
72+
Then I should match stdout with "Success"
73+
74+
Scenario: Dump ES data to a snapshot into a repository
75+
When I run the command "es:snapshot:create" with:
76+
| arg | backup | |
77+
| arg | test-snapshot | |
78+
Then I should match stdout with "Success"
79+
80+
Scenario: List all available snapshot of a repository
81+
When I run the command "es:snapshot:list" with:
82+
| arg | backup | |
83+
Then I should match stdout with "test-snapshot"
84+
85+
Scenario: Restore ES data from a snapshot
86+
When I run the command "es:snapshot:restore" with:
87+
| arg | backup | |
88+
| arg | test-snapshot | |
89+
Then I should match stdout with "Success"

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "kourou",
33
"description": "The CLI that helps you manage your Kuzzle instances",
4-
"version": "0.28.0",
4+
"version": "0.28.1",
55
"author": "The Kuzzle Team <[email protected]>",
66
"bin": {
77
"kourou": "./bin/run"

src/commands/es/snapshot/create.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export default class EsSnapshotsCreate extends Kommand {
2828
const esRequest = {
2929
repository: this.args.repository,
3030
snapshot: this.args.name,
31-
body: {},
31+
body: {
32+
indices: "*",
33+
include_global_state: false,
34+
partial: false,
35+
},
3236
};
3337

3438
const response = await esClient.snapshot.create(esRequest);

src/commands/es/snapshot/restore.ts

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { flags } from "@oclif/command";
2+
import { Client } from "@elastic/elasticsearch";
3+
4+
import { Kommand } from "../../../common";
5+
6+
export default class EsSnapshotsRestore extends Kommand {
7+
static initSdk = false;
8+
9+
static description = "Restore a snapshot repository inside an ES instance";
10+
11+
static flags = {
12+
node: flags.string({
13+
char: "n",
14+
description: "Elasticsearch server URL",
15+
default: "http://localhost:9200",
16+
}),
17+
help: flags.help(),
18+
};
19+
20+
static args = [
21+
{ name: "repository", description: "ES repository name", required: true },
22+
{ name: "name", description: "ES snapshot name", required: true },
23+
];
24+
25+
async runSafe() {
26+
const esClient = new Client({ node: this.flags.node });
27+
28+
await esClient.indices.close({
29+
index: "*",
30+
expand_wildcards: "all",
31+
});
32+
33+
const esRequest = {
34+
repository: this.args.repository,
35+
snapshot: this.args.name,
36+
body: {
37+
feature_states: ["none"],
38+
include_global_state: false,
39+
indices: "*",
40+
},
41+
};
42+
43+
const response = await esClient.snapshot.restore(esRequest);
44+
45+
this.logOk(`Success ${JSON.stringify(response.body)}`);
46+
}
47+
}

0 commit comments

Comments
 (0)