You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/website/content/commands/snapshot/save.mdx

68 lines
2.3 KiB

---
layout: commands
page_title: 'Commands: Snapshot Save'
---
# Consul Snapshot Save
Command: `consul snapshot save`
The `snapshot save` command is used to retrieve an atomic, point-in-time snapshot
of the state of the Consul servers which includes key/value entries,
service catalog, prepared queries, sessions, and ACLs. The snapshot is saved to
the given file.
If ACLs are enabled, a management token must be supplied in order to perform
a snapshot save.
-> Note that saving a snapshot involves the server process writing the snapshot to a
temporary file on-disk before sending that file to the CLI client. The default location
can vary depending on operating system, but typically is `/tmp`. You can get more detailed
information on default locations in the Go documentation for [os.TempDir](https://golang.org/pkg/os/#TempDir).
If you need to change this location, you can do so by setting the `TMPDIR` environment
variable for the Consul server processes. Keep in mind that setting the environment variable for
the CLI client attempting to perform a snapshot save will have no effect. It _must_ be set in
the context of the server process. If you're using Systemd to manage your Consul server
processes, then adding `Environment=TMPDIR=/path/to/dir` to your Consul unit file will work.
## Usage
Usage: `consul snapshot save [options] FILE`
#### API Options
@include 'http_api_options_client.mdx'
@include 'http_api_options_server.mdx'
## Examples
To create a snapshot from the leader server and save it to "backup.snap":
```shell-session
$ consul snapshot save backup.snap
Saved and verified snapshot to index 8419
```
By default, snapshots are taken using a consistent mode that forwards requests
to the leader and the leader verifies it is still in power before taking the
snapshot.
After the snapshot is written to the given file it is read back and verified for
integrity.
To create a potentially stale snapshot from any available server, use the stale
consistency mode:
```shell-session
$ consul snapshot save -stale backup.snap
# ...
```
This is useful for situations where a cluster is in a degraded state and no
leader is available. To target a specific server for a snapshot, you can run
the `consul snapshot save` command on that specific server.
Please see the [HTTP API](/api/snapshot) documentation for
more details about snapshot internals.