Skip to content

Commit d0c90e3

Browse files
author
sangam14
committed
etcd-backup
1 parent 43b9c00 commit d0c90e3

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

content/docs/kubernetes/HA-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "HA Cluster"
33
description: " Manage a Highly-Available Kubernetes Cluster "
44
slug: "HA Cluster"
5-
weight: 810
5+
weight: 4
66
---
77

88

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "etcd Backup and Restore"
3+
description: "etcd Backup and Restore"
4+
weight: 5
5+
---
6+
7+
8+
9+
10+
etcd Backup and Restore
11+
12+
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.
13+
14+
### install etcd
15+
```
16+
sudo apt install etcd
17+
```
18+
find server.crt
19+
20+
```
21+
sangam@sangam:~$ sudo find / -name server.crt 2>/dev/null
22+
/etc/kubernetes/pki/etcd/server.crt
23+
```
24+
## take backup
25+
26+
```
27+
sangam@sangam:~$ sudo ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
28+
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
29+
--cert=/etc/kubernetes/pki/etcd/server.crt \
30+
--key=/etc/kubernetes/pki/etcd/server.key \
31+
snapshot save /var/lib/etcd/backup.db
32+
2024-04-26 03:53:42.172131 I | clientv3: opened snapshot stream; downloading
33+
2024-04-26 03:53:42.188033 I | clientv3: completed snapshot read; closing
34+
Snapshot saved at /var/lib/etcd/backup.db
35+
```
36+
37+
38+
### check snapshot
39+
40+
```
41+
42+
sangam@sangam:~$ sudo ls -lh /var/lib/etcd/backup.db
43+
-rw-r--r-- 1 root root 3.2M Apr 26 03:53 /var/lib/etcd/backup.db
44+
```

0 commit comments

Comments
 (0)