# データベースの保存方法

> etcdデータベースのスナップショットを取得するためのガイド

---

LLMSインデックス: [llms.txt](/ja/llms.txt)

---

## 前提条件 {#pre-requisites}

* [etcdctlとetcdutlをインストール](/ja/docs/etcd/install/)します。
* [ローカルクラスターをセットアップ](/ja/docs/etcd/dev-guide/local_cluster/)します。

## データベースのスナップショットを取得する {#snapshot-a-database}

etcdデータベースのある時点のスナップショットを保存する`snapshot`：

```bash
etcdctl --endpoints=$ENDPOINT snapshot save DB_NAME
```

### グローバルオプション {#global-options}

#### etcdctl {#etcdctl}

```bash
--endpoints=[127.0.0.1:2379], gRPC endpoints
```

スナップショットを要求できるetcdノードは1つだけなので、`--endpoints`フラグにはエンドポイントを1つだけ指定する必要があります。

#### etcdutl {#etcdutl}

```bash
-w, --write-out string   set the output format (fields, json, protobuf, simple, table) (default "simple")
```

### 例 {#example}

![11_etcdctl_snapshot_2016051001](/docs/etcd/tasks/img/save-database.gif)

```shell
ENDPOINTS=$HOST_1:2379
etcdctl --endpoints=$ENDPOINTS snapshot save my.db

Snapshot saved at my.db
```

```shell
etcdutl --write-out=table snapshot status my.db

+---------+----------+------------+------------+
|  HASH   | REVISION | TOTAL KEYS | TOTAL SIZE |
+---------+----------+------------+------------+
| c55e8b8 |        9 |         13 | 25 kB      |
+---------+----------+------------+------------+
```
