...
Now we will use the snapshot backup to restore etcd as shown below. The restore
command generates the member
directory, which will be pasted into the path where the etcd node data are stored (the default path is /var/lib/etcd/
). If you want to use a specific data directory for the restore, you can add the location using the --data-dir
flag, but the destination directory must be empty and obviously have write permissions.
Code Block |
---|
language | bash |
---|
title | Restore snapshot |
---|
|
# Repeat this command for all etcd members
$ etcdctl snapshot restore <path>/<snapshot> [--data-dir <data_dir>] --name etcd1 --initial-cluster etcd1=https://<IP1>:2380,etcd2=https://<IP2>:2380,etcd3=https://<IP3>:2380 --initial-cluster-token <token> --initial-advertise-peer-urls https://<IP1>:2380
# For instance
$ etcdctl snapshot restore snapshot.db --data-dir /tmp/snaprestore_dirsnap1 --name etcd1 --initial-cluster etcd1=https://etcd1:2380,etcd2=https://etcd2:2380,etcd3=https://etcd3:2380 --initial-cluster-token k8s_etcd --initial-advertise-peer-urls https://etcd1:2380
#$ Paste the snapshot into the path where the etcd node data are storedetcdctl snapshot restore snapshot.db --data-dir /tmp/restore_snap2 --name etcd2 --initial-cluster etcd1=https://etcd1:2380,etcd2=https://etcd2:2380,etcd3=https://etcd3:2380 --initial-cluster-token k8s_etcd --initial-advertise-peer-urls https://etcd2:2380
$ etcdctl snapshot restore snapshot.db --data-dir /tmp/restore_snap3 --name etcd3 --initial-cluster etcd1=https://etcd1:2380,etcd2=https://etcd2:2380,etcd3=https://etcd3:2380 --initial-cluster-token k8s_etcd --initial-advertise-peer-urls https://etcd3:2380
# Paste the snapshot into the path where the etcd node data are stored
$ cp -r /tmp/snap_dir1/member /var/lib/etcd/ |
The restore
command generates the member
directory, which will be pasted into the path where the etcd node data are stored (the default path is /var/lib/etcd/
)
Code Block |
---|
language | bash |
---|
title | Copy snapshot |
---|
|
# Paste the snapshot into the path where the etcd node data are stored
$ cp -r <path>/<restore> /var/lib/etcd/
# For each etcd node
$ cp -r /tmp/restore_snap1/member /var/lib/etcd/
$ cp -r /tmp/restore_snap2/member /var/lib/etcd/
$ cp -r /tmp/snaprestore_dirsnap3/member /var/lib/etcd/ |