From 2ddb9f40a274f032ca87af78aca86fd9ead92fd5 Mon Sep 17 00:00:00 2001 From: Ais8Ooz8 <47941654+Ais8Ooz8@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:34:20 +0300 Subject: [PATCH] etcdctl: add etcdctl snapshot pipe command To improve the security of etcdctl. Added the ability to write snapshots to stdout without writing data to disk. Signed-off-by: Ais8Ooz8 <47941654+Ais8Ooz8@users.noreply.github.com> --- CHANGELOG/CHANGELOG-3.6.md | 1 + client/v3/snapshot/v3_snapshot.go | 2 +- etcdctl/README.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG/CHANGELOG-3.6.md b/CHANGELOG/CHANGELOG-3.6.md index 08924e1cd..defb4da88 100644 --- a/CHANGELOG/CHANGELOG-3.6.md +++ b/CHANGELOG/CHANGELOG-3.6.md @@ -28,6 +28,7 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.6.0). ### etcdctl v3 - Add command to generate [shell completion](https://github.com/etcd-io/etcd/pull/13133). +- Add command [snapshot pipe](https://github.com/etcd-io/etcd/pull/16243). - When print endpoint status, [show db size in use](https://github.com/etcd-io/etcd/pull/13639) - [Always print the raft_term in decimal](https://github.com/etcd-io/etcd/pull/13711) when displaying member list in json. - [Add one more field `storageVersion`](https://github.com/etcd-io/etcd/pull/13773) into the response of command `etcdctl endpoint status`. diff --git a/client/v3/snapshot/v3_snapshot.go b/client/v3/snapshot/v3_snapshot.go index f6cdb0b3a..20cf01392 100644 --- a/client/v3/snapshot/v3_snapshot.go +++ b/client/v3/snapshot/v3_snapshot.go @@ -44,7 +44,7 @@ func hasChecksum(n int64) bool { // context.DeadlineExceeded). Make sure to specify only one endpoint // in client configuration. Snapshot API must be requested to a // selected node, and saved snapshot is the point-in-time state of -// the selected node. Etcd < v3.6 will return "" as version. +// the selected node. Nota bene: etcd < v3.6 will return "" as version. func WriteSnapshotWithVersion(ctx context.Context, lg *zap.Logger, cfg clientv3.Config, f *os.File) (string, error) { cfg.Logger = lg.Named("client") if len(cfg.Endpoints) != 1 { diff --git a/etcdctl/README.md b/etcdctl/README.md index e654eff49..5cc825cd8 100644 --- a/etcdctl/README.md +++ b/etcdctl/README.md @@ -1024,7 +1024,7 @@ The backend snapshot is written to stdout. Write a snapshot to stdout: ``` -./etcdctl snapshot pipe +./etcdctl snapshot pipe > snapshot.db ``` ### SNAPSHOT SAVE \