2023-03-28 19:12:30 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 19:12:30 +00:00
|
|
|
|
2017-10-17 06:56:35 +00:00
|
|
|
package snapshot
|
2016-10-26 02:20:24 +00:00
|
|
|
|
|
|
|
import (
|
2017-10-17 13:44:20 +00:00
|
|
|
"github.com/hashicorp/consul/command/flags"
|
2016-10-26 02:20:24 +00:00
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
)
|
|
|
|
|
2017-10-17 06:56:35 +00:00
|
|
|
func New() *cmd {
|
|
|
|
return &cmd{}
|
2016-10-26 02:20:24 +00:00
|
|
|
}
|
|
|
|
|
2017-10-17 06:56:35 +00:00
|
|
|
type cmd struct{}
|
|
|
|
|
|
|
|
func (c *cmd) Run(args []string) int {
|
2016-10-26 02:20:24 +00:00
|
|
|
return cli.RunResultHelp
|
|
|
|
}
|
|
|
|
|
2017-10-17 06:56:35 +00:00
|
|
|
func (c *cmd) Synopsis() string {
|
2017-10-17 13:44:20 +00:00
|
|
|
return synopsis
|
2017-10-17 06:56:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cmd) Help() string {
|
2017-10-17 22:00:01 +00:00
|
|
|
return flags.Usage(help, nil)
|
2017-10-17 13:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const synopsis = "Saves, restores and inspects snapshots of Consul server state"
|
|
|
|
const help = `
|
|
|
|
Usage: consul snapshot <subcommand> [options] [args]
|
2016-10-26 02:20:24 +00:00
|
|
|
|
2016-10-31 23:37:27 +00:00
|
|
|
This 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.
|
2016-10-26 02:20:24 +00:00
|
|
|
|
|
|
|
If ACLs are enabled, a management token must be supplied in order to perform
|
|
|
|
snapshot operations.
|
|
|
|
|
|
|
|
Create a snapshot:
|
|
|
|
|
|
|
|
$ consul snapshot save backup.snap
|
|
|
|
|
|
|
|
Restore a snapshot:
|
|
|
|
|
|
|
|
$ consul snapshot restore backup.snap
|
|
|
|
|
2016-10-31 23:37:27 +00:00
|
|
|
Inspect a snapshot:
|
|
|
|
|
|
|
|
$ consul snapshot inspect backup.snap
|
|
|
|
|
2017-10-11 22:52:20 +00:00
|
|
|
Run a daemon process that locally saves a snapshot every hour (available only in
|
|
|
|
Consul Enterprise) :
|
2016-10-26 02:20:24 +00:00
|
|
|
|
2017-10-11 22:52:20 +00:00
|
|
|
$ consul snapshot agent
|
2016-10-26 02:20:24 +00:00
|
|
|
|
2017-10-11 22:52:20 +00:00
|
|
|
For more examples, ask for subcommand help or view the documentation.
|
2016-10-26 02:20:24 +00:00
|
|
|
`
|