Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.28.1 #205

Merged
merged 14 commits into from
Jan 24, 2024
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $ npm install -g kourou
$ kourou COMMAND
running command...
$ kourou (-v|--version|version)
kourou/0.28.0 darwin-arm64 node-v20.10.0
kourou/0.28.1 darwin-arm64 node-v20.10.0
$ kourou --help [COMMAND]
USAGE
$ kourou COMMAND
Expand Down Expand Up @@ -149,6 +149,7 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
* [`kourou es:snapshot:create REPOSITORY NAME`](#kourou-essnapshotcreate-repository-name)
* [`kourou es:snapshot:create-repository REPOSITORY LOCATION`](#kourou-essnapshotcreate-repository-repository-location)
* [`kourou es:snapshot:list REPOSITORY`](#kourou-essnapshotlist-repository)
* [`kourou es:snapshot:restore REPOSITORY NAME`](#kourou-essnapshotrestore-repository-name)
* [`kourou file:decrypt FILE`](#kourou-filedecrypt-file)
* [`kourou file:encrypt FILE`](#kourou-fileencrypt-file)
* [`kourou file:test FILE`](#kourou-filetest-file)
Expand Down Expand Up @@ -795,6 +796,23 @@ OPTIONS

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

## `kourou es:snapshot:restore REPOSITORY NAME`

Restore a snapshot repository inside an ES instance

```
USAGE
$ kourou es:snapshot:restore REPOSITORY NAME

ARGUMENTS
REPOSITORY ES repository name
NAME ES snapshot name

OPTIONS
-n, --node=node [default: http://localhost:9200] Elasticsearch server URL
--help show CLI help
```

## `kourou file:decrypt FILE`

Decrypts an encrypted file.
Expand Down
65 changes: 35 additions & 30 deletions features/Elasticsearch.feature → features/Z_Elasticsearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,7 @@ Feature: Elasticsearch commands
Then I should match stdout with "{"index": "%kuzzle.users", "alias": "@%kuzzle.users"}"

@mappings
Scenario: Insert ES document
Given a collection "nyc-open-data":"green-taxi"
When I run the command "es:indices:insert" with:
| arg | &nyc-open-data.yellow-taxi | |
| flag | --id | kindred |
| flag | --body | {} |
When I run the command "es:indices:get" with args:
| "&nyc-open-data.yellow-taxi" |
| "kindred" |
Then I should match stdout with "kindred"

Scenario: Create a snapshot repository
When I run the command "es:snapshot:create-repository" with:
| arg | backup | |
| arg | /tmp/snapshots | |
| flag | --compress | |
Then I should match stdout with "Success"

Scenario: Dump ES data to a snapshot into a repository
When I run the command "es:snapshot:create" with:
| arg | backup | |
| arg | test-snapshot | |
Then I should match stdout with "Success"

Scenario: List all available snapshot of a repository
When I run the command "es:snapshot:list" with:
| arg | backup | |
Then I should match stdout with "test-snapshot"

Scenario: Dump and restore ES data to a dump folder using the pattern option
Given an index "nyc-open-data"
Given a collection "nyc-open-data":"yellow-taxi"
Then I create the following document:
| _id | "chuon-chuon-kim" |
Expand All @@ -82,3 +52,38 @@ Feature: Elasticsearch commands
Given an existing collection "nyc-open-data":"yellow-taxi"
Then I refresh the collection
And I count 3 documents

Scenario: Insert ES document
Given a collection "nyc-open-data":"blue-taxi"
When I run the command "es:indices:insert" with:
| arg | &nyc-open-data.blue-taxi | |
| flag | --id | kindred |
| flag | --body | {} |
When I run the command "es:indices:get" with args:
| "&nyc-open-data.blue-taxi" |
| "kindred" |
Then I should match stdout with "kindred"

Scenario: Create a snapshot repository
When I run the command "es:snapshot:create-repository" with:
| arg | backup | |
| arg | /tmp/snapshots | |
| flag | --compress | |
Then I should match stdout with "Success"

Scenario: Dump ES data to a snapshot into a repository
When I run the command "es:snapshot:create" with:
| arg | backup | |
| arg | test-snapshot | |
Then I should match stdout with "Success"

Scenario: List all available snapshot of a repository
When I run the command "es:snapshot:list" with:
| arg | backup | |
Then I should match stdout with "test-snapshot"

Scenario: Restore ES data from a snapshot
When I run the command "es:snapshot:restore" with:
| arg | backup | |
| arg | test-snapshot | |
Then I should match stdout with "Success"
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kourou",
"description": "The CLI that helps you manage your Kuzzle instances",
"version": "0.28.0",
"version": "0.28.1",
"author": "The Kuzzle Team <[email protected]>",
"bin": {
"kourou": "./bin/run"
Expand Down
6 changes: 5 additions & 1 deletion src/commands/es/snapshot/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export default class EsSnapshotsCreate extends Kommand {
const esRequest = {
repository: this.args.repository,
snapshot: this.args.name,
body: {},
body: {
indices: "*",
include_global_state: false,
partial: false,
},
};

const response = await esClient.snapshot.create(esRequest);
Expand Down
47 changes: 47 additions & 0 deletions src/commands/es/snapshot/restore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { flags } from "@oclif/command";
import { Client } from "@elastic/elasticsearch";

import { Kommand } from "../../../common";

export default class EsSnapshotsRestore extends Kommand {
static initSdk = false;

static description = "Restore a snapshot repository inside an ES instance";

static flags = {
node: flags.string({
char: "n",
description: "Elasticsearch server URL",
default: "http://localhost:9200",
}),
help: flags.help(),
};

static args = [
{ name: "repository", description: "ES repository name", required: true },
{ name: "name", description: "ES snapshot name", required: true },
];

async runSafe() {
const esClient = new Client({ node: this.flags.node });

await esClient.indices.close({
index: "*",
expand_wildcards: "all",
});

const esRequest = {
repository: this.args.repository,
snapshot: this.args.name,
body: {
feature_states: ["none"],
include_global_state: false,
indices: "*",
},
};

const response = await esClient.snapshot.restore(esRequest);

this.logOk(`Success ${JSON.stringify(response.body)}`);
}
}
Loading