Clarification when using etcd –data-dir

Hi,

This is related to the use of –data-dir option.

In some examples I see no change required to the new folder permission (so remains with root:root).
In others I see that permissions are changed to (etcd:etcd) with chmod +R etcd:etcd /var/lib/etcd-from-backup

Which is the correct way as the documentation does not specifically mention that a change of permissions is needed when creating a new folder?

Thanks

Hello @andrea_conti,
The data-dir is inside the pod itself, and no need to have a user is called etcd on the system to take backup and restore.
You can follow the mentioned steps in this repo GitHub - mmumshad/kubernetes-cka-practice-test-solution-etcd-backup-and-restore: This is the solution to the practice test for backing up and restoring an ETCD Cluster

Thanks,
KodeKloud Support

1 Like

Ok in the example you shared why a new cluster is being created, are the 4 steps below enough fine as think would be simpler:

    • Manifests moved to temporary directory
    • ETCDCTL_API=3 etcdctl --data-dir /var/lib/etcd-from-backup snapshot restore snapshotdb
    • ETCD Manifest file Host Path updated to reflect the new path (/var/lib/etcd-from-backup)
    • Manifests moved back to /etc/kubernetes/manifests/

Ref: https://github.com/mmumshad/kubernetes-the-hard-way/blob/master/practice-questions-answers/cluster-maintenance/backup-etcd/etcd-backup-and-restore.md#3-restore-etcd-snapshot-to-a-new-folder