From d0c90e30d9df463d8f7bb7632abba665195e2b0b Mon Sep 17 00:00:00 2001 From: sangam14 Date: Fri, 26 Apr 2024 09:30:45 +0530 Subject: [PATCH] etcd-backup --- content/docs/kubernetes/HA-cluster.md | 2 +- content/docs/kubernetes/etcd-backup | 44 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 content/docs/kubernetes/etcd-backup diff --git a/content/docs/kubernetes/HA-cluster.md b/content/docs/kubernetes/HA-cluster.md index c1621cb..4f40249 100644 --- a/content/docs/kubernetes/HA-cluster.md +++ b/content/docs/kubernetes/HA-cluster.md @@ -2,7 +2,7 @@ title: "HA Cluster" description: " Manage a Highly-Available Kubernetes Cluster " slug: "HA Cluster" -weight: 810 +weight: 4 --- diff --git a/content/docs/kubernetes/etcd-backup b/content/docs/kubernetes/etcd-backup new file mode 100644 index 0000000..9bd597b --- /dev/null +++ b/content/docs/kubernetes/etcd-backup @@ -0,0 +1,44 @@ +--- +title: "etcd Backup and Restore" +description: "etcd Backup and Restore" +weight: 5 +--- + + + + +etcd Backup and Restore + +Etcd maintains the active state of the cluster, with the API Servers interacting by writing to and retrieving data from it. Each transaction executed in etcd is logged in a Write-Ahead Log (WAL) file specific to each cluster member. These files, which are updated by transactions initiated by the cluster's "leader," are periodically condensed into snapshots to conserve space. This snapshotting process is an integral part of etcd's routine operations, and snapshots can also be manually triggered using the etcdctl tool with the `snapshot save` command. + +### install etcd +``` +sudo apt install etcd +``` +find server.crt + +``` +sangam@sangam:~$ sudo find / -name server.crt 2>/dev/null +/etc/kubernetes/pki/etcd/server.crt +``` +## take backup + +``` +sangam@sangam:~$ sudo ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \ + --cacert=/etc/kubernetes/pki/etcd/ca.crt \ + --cert=/etc/kubernetes/pki/etcd/server.crt \ + --key=/etc/kubernetes/pki/etcd/server.key \ + snapshot save /var/lib/etcd/backup.db +2024-04-26 03:53:42.172131 I | clientv3: opened snapshot stream; downloading +2024-04-26 03:53:42.188033 I | clientv3: completed snapshot read; closing +Snapshot saved at /var/lib/etcd/backup.db +``` + + +### check snapshot + +``` + +sangam@sangam:~$ sudo ls -lh /var/lib/etcd/backup.db +-rw-r--r-- 1 root root 3.2M Apr 26 03:53 /var/lib/etcd/backup.db +```