- Creating a snapshot file
- Inspecting snapshot metadata
- Restoring a cluster from a snapshot
Prerequisites
- A running Consul server (open source) cluster
- Consul CLI installed and in your
$PATH - Permissions to read/write snapshot files
Ensure you have sufficient disk space in your working directory before creating large snapshots.
1. Taking a Snapshot
- SSH into one of your Consul server nodes.
- Change to a writable directory (e.g.,
/tmp): - Run the
savesubcommand to generate a snapshot file: - Confirm the operation:
- Verify the file exists:
2. Inspecting a Snapshot
To view metadata about an existing snapshot file, use theinspect subcommand:
- The Version field refers to the snapshot format, not the Consul binary version.
- Index and Term reflect the Raft state at snapshot creation.
3. Restoring a Snapshot
When recovering a failed cluster or migrating state, restore from your snapshot:- Restart all Consul agents or services to load the restored data.
- Check cluster status:
Do not restore a snapshot into an active cluster without first stopping agents—this can lead to data corruption.
Snapshot Commands Reference
| Command | Description | Example Usage |
|---|---|---|
consul snapshot save | Create a new snapshot file | consul snapshot save backup.snap |
consul snapshot inspect | Show metadata for a snapshot | consul snapshot inspect backup.snap |
consul snapshot restore | Restore state from a snapshot file | consul snapshot restore backup.snap |
Links and References
By following these steps, you can efficiently manage Consul snapshots, ensuring reliable backups and quick recovery for your service cluster.