1

I have setup a kubernetes cluster with 2 master nodes and 4 worker nodes, I am trying to do an etcd backup as described in the documentation inside my etcd container.

‍ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
  --cacert=<trusted-ca-file> --cert=<cert-file> --key=<key-file> \
  snapshot save <backup-file-location>

but I get the following error:

Error: unknown command "save" for "etcdctl"

Are there something to concider upfront?

Andromeda
  • 1,205
  • 1
  • 14
  • 21
pwoltschk
  • 550
  • 1
  • 3
  • 22

3 Answers3

1

To me it sounds like you have a version mismatch between your client and the API.

You can run etcdctl version to see what version you're using and make sure the client doesn't use an obsolete version.

More details here.

Will
  • 1,792
  • 2
  • 23
  • 44
1

Check first if this is similar to this question

I forgot to set $ENDPOINT.

That can happen if the --endpoints flag is not correctly followed by an actual endpoint.
In your case, because of the lack of a specified endpoint after the --endpoints flag, etcdctl is interpreting "snapshot" as the endpoint, and "save" as the command - which could result in the error you are seeing.

A better formed command would be:

ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
  --cacert=<trusted-ca-file> --cert=<cert-file> --key=<key-file> \
  snapshot save <backup-file-location>

Do replace <trusted-ca-file>, <cert-file>, <key-file>, and <backup-file-location> with your actual file paths.

The --endpoints flag specifies the endpoint to connect to your etcd server. In a Kubernetes cluster, you typically connect to the etcd server through localhost (127.0.0.1) on port 2379, which is the default etcd client port.


Also, just in case, in some shells, using the \ character for line continuation might cause issues, try running the command all on one line:

ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert=<trusted-ca-file> --cert=<cert-file> --key=<key-file> snapshot save <backup-file-location>

Another issue might be that the <backup-file-location> you are specifying does not exist or the etcdctl does not have permission to write to it. Make sure the directory you are trying to save the snapshot to exists and that the user running the etcdctl command has permission to write to it.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

etcdctl tries to run the command save, like etcdctl save <backup-file-location> and since there is no save command, you get the error.

I'm guessing you're using environment variables. Check if those are set, otherwise the arguments are shifted and etcdctl tries to execute the command save instead of snapshot save, like:

ETCDCTL_API=3 etcdctl 
  --endpoints $ENDPOINT \
  --cacert $CA \
  --cert $CRT \
  --key $KEY \
  snapshot save <backup-file-location>

becomes

ETCDCTL_API=3 etcdctl 
  --endpoints <some-url> \
  --cacert <some-path> 
  --cert <some-path> \ 
  --key snapshot \
  save <backup-file-location>
Chris
  • 5,109
  • 3
  • 19
  • 40