2016-10-26 02:20:24 +00:00
|
|
|
---
|
2020-04-07 18:55:19 +00:00
|
|
|
layout: docs
|
2020-04-06 20:27:35 +00:00
|
|
|
page_title: 'Commands: Snapshot'
|
2020-04-13 18:40:26 +00:00
|
|
|
sidebar_title: snapshot
|
2016-10-26 02:20:24 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul Snapshot
|
|
|
|
|
|
|
|
Command: `consul snapshot`
|
|
|
|
|
2016-10-31 23:37:27 +00:00
|
|
|
The `snapshot` command has subcommands for saving, restoring, and inspecting the
|
|
|
|
state of the Consul servers for disaster recovery. These are atomic, point-in-time
|
|
|
|
snapshots which include key/value entries, service catalog, prepared queries,
|
|
|
|
sessions, and ACLs. This command is available in Consul 0.7.1 and later.
|
2016-10-26 02:20:24 +00:00
|
|
|
|
2020-04-09 23:46:54 +00:00
|
|
|
Snapshots are also accessible via the [HTTP API](/api/snapshot).
|
2016-10-26 02:20:24 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul snapshot <subcommand>`
|
|
|
|
|
|
|
|
For the exact documentation for your Consul version, run `consul snapshot -h` to
|
|
|
|
view the complete list of subcommands.
|
|
|
|
|
|
|
|
```text
|
|
|
|
Usage: consul snapshot <subcommand> [options] [args]
|
|
|
|
|
|
|
|
# ...
|
|
|
|
|
|
|
|
Subcommands:
|
|
|
|
|
2016-11-17 05:38:02 +00:00
|
|
|
agent Periodically saves snapshots of Consul server state
|
2016-10-31 23:37:27 +00:00
|
|
|
inspect Displays information about a Consul snapshot file
|
2016-10-26 02:20:24 +00:00
|
|
|
restore Restores snapshot of Consul server state
|
|
|
|
save Saves snapshot of Consul server state
|
|
|
|
```
|
|
|
|
|
|
|
|
For more information, examples, and usage about a subcommand, click on the name
|
|
|
|
of the subcommand in the sidebar or one of the links below:
|
|
|
|
|
2020-04-09 23:46:54 +00:00
|
|
|
- [agent](/docs/commands/snapshot/agent) (Consul Enterprise only)
|
|
|
|
- [inspect](/docs/commands/snapshot/inspect)
|
|
|
|
- [restore](/docs/commands/snapshot/restore)
|
|
|
|
- [save](/docs/commands/snapshot/save)
|
2016-10-26 02:20:24 +00:00
|
|
|
|
|
|
|
## Basic Examples
|
|
|
|
|
|
|
|
To create a snapshot and save it as a file called "backup.snap":
|
|
|
|
|
|
|
|
```text
|
|
|
|
$ consul snapshot save backup.snap
|
|
|
|
Saved and verified snapshot to index 8419
|
|
|
|
```
|
|
|
|
|
|
|
|
To restore a snapshot from a file called "backup.snap":
|
|
|
|
|
|
|
|
```text
|
|
|
|
$ consul snapshot restore backup.snap
|
|
|
|
Restored snapshot
|
|
|
|
```
|
|
|
|
|
2016-10-31 23:37:27 +00:00
|
|
|
To inspect a snapshot from the file "backup.snap":
|
|
|
|
|
|
|
|
```text
|
|
|
|
$ consul snapshot inspect backup.snap
|
|
|
|
ID 2-5-1477944140022
|
|
|
|
Size 667
|
|
|
|
Index 5
|
|
|
|
Term 2
|
|
|
|
Version 1
|
|
|
|
```
|
|
|
|
|
2016-11-17 05:38:02 +00:00
|
|
|
To run a daemon process that periodically saves snapshots (Consul Enterprise only):
|
|
|
|
|
|
|
|
```
|
|
|
|
$ consul snapshot agent
|
|
|
|
```
|
|
|
|
|
2016-10-26 02:20:24 +00:00
|
|
|
For more examples, ask for subcommand help or view the subcommand documentation
|
|
|
|
by clicking on one of the links in the sidebar.
|