|  | 
|  | 1 | +--- | 
|  | 2 | +layout: docs | 
|  | 3 | +page_title: 'Single Item Recovery' | 
|  | 4 | +description: >- | 
|  | 5 | +  TODO | 
|  | 6 | +--- | 
|  | 7 | + | 
|  | 8 | +# Single item recovery in Vault  | 
|  | 9 | + | 
|  | 10 | +When a secret is accidentally changed or deleted, Secret Recovery provides the ability  | 
|  | 11 | +to restore specific supported items from a previously taken snapshot. This is a more  | 
|  | 12 | +targeted and flexible operation than the alternative, restoring the entire cluster  | 
|  | 13 | +from a snapshot, and is much safer to delegate to specific users. | 
|  | 14 | + | 
|  | 15 | +The **Secrets Recovery** page  | 
|  | 16 | +in the Vault GUI provides the ability to load and unload snapshots to the cluster,  | 
|  | 17 | +which can then be used in recovery operations. Supported resource types can then be  | 
|  | 18 | +recovered or read from the snapshot via the GUI. (This provides the additional benefit of  | 
|  | 19 | +allowing customers insight into what is contained within the snapshot, even if no  | 
|  | 20 | +recovery operation is performed.) You can also use the Vault CLI or API to perform snapshot operations. | 
|  | 21 | + | 
|  | 22 | +**Supported resource types**: KV v1 secrets, Cubbyhole secrets, Database static roles   | 
|  | 23 | +(please note: SSH keys are currently supported by the backend, but do not yet have frontend support) | 
|  | 24 | + | 
|  | 25 | +Automatic snapshot configurations can also be configured to automatically load the snapshot to Vault  | 
|  | 26 | +itself, making it available for recovery. Snapshot management permissions are separate from recovery  | 
|  | 27 | +permissions so that recovery operations can be delegated but controlled. | 
|  | 28 | + | 
|  | 29 | +Additionally, rather than recovering a previous version of a secret to the same path and  | 
|  | 30 | +overwriting the current version of that secret, it is possible to “recover as a copy” and  | 
|  | 31 | +restore the previous version to a new path, thus maintaining both. | 
|  | 32 | + | 
|  | 33 | +## Policy Examples | 
|  | 34 | +1. Allow Snapshot Management  | 
|  | 35 | +    ```hcl | 
|  | 36 | +    path "sys/storage/raft/snapshot-load" { | 
|  | 37 | +        capabilities = ["update"] | 
|  | 38 | +    } | 
|  | 39 | +    ``` | 
|  | 40 | + | 
|  | 41 | +2. Allow Recovery | 
|  | 42 | +    ```hcl | 
|  | 43 | +    path "secrets/*" { | 
|  | 44 | +        capabilities = ["recover"] | 
|  | 45 | +    } | 
|  | 46 | +    ``` | 
|  | 47 | + | 
|  | 48 | +3. Restrict Read  | 
|  | 49 | +    ```hcl | 
|  | 50 | +    path "secrets/*" { | 
|  | 51 | +        capabilities = ["read", "list"] | 
|  | 52 | +        denied_parameters = { | 
|  | 53 | +            read_snapshot_id = [] | 
|  | 54 | +        } | 
|  | 55 | +    } | 
|  | 56 | +    ``` | 
|  | 57 | + | 
|  | 58 | +## Upload a snapshot | 
|  | 59 | + | 
|  | 60 | +Snapshots can be provided in the form of automated snapshots in cloud storage or manual snapshots  | 
|  | 61 | +uploaded from a local file. Automated snapshots can be configured to auto load the snapshot to the cluster. | 
|  | 62 | + | 
|  | 63 | + | 
|  | 64 | +<Tabs> | 
|  | 65 | +<Tab heading="Web UI" group="ui"> | 
|  | 66 | + | 
|  | 67 | +1. Open a web browser to access the Vault UI and sign in to the root namespace. | 
|  | 68 | +   <Tip title="Namespace restriction"> | 
|  | 69 | + | 
|  | 70 | +   Snapshot load and unload operations are restricted to the root namespace. All other snapshot operations  | 
|  | 71 | +   can be performed in other namespaces.  | 
|  | 72 | + | 
|  | 73 | +    </Tip> | 
|  | 74 | + | 
|  | 75 | +    <Tip title="Permissions Required"> | 
|  | 76 | +        This requires snapshot management permissions. | 
|  | 77 | +    </Tip> | 
|  | 78 | + | 
|  | 79 | +2. Select **Secrets Recovery** from the left navigation menu. | 
|  | 80 | + | 
|  | 81 | +3. Select **Upload snapshot**. | 
|  | 82 | +     | 
|  | 83 | + | 
|  | 84 | +4. Select the method of upload. If loading from **automated** snapshots, an automated snapshot config is required. | 
|  | 85 | +Refer to the [automated snapshot API](https://developer.hashicorp.com/vault/api-docs/system/storage/raftautosnapshots#load-a-snapshot-from-an-automated-snapshot-configuration)  | 
|  | 86 | +to learn more about automated snapshots. | 
|  | 87 | +     | 
|  | 88 | + | 
|  | 89 | +5. Click **Load snapshot** to complete the upload. | 
|  | 90 | + | 
|  | 91 | + | 
|  | 92 | +</Tab> | 
|  | 93 | +<Tab heading="API call using cURL" group="api"> | 
|  | 94 | + | 
|  | 95 | +@include 'alerts/restricted-root.mdx' | 
|  | 96 | + | 
|  | 97 | +**Example of an automated snapshot upload:** | 
|  | 98 | +```shell-session | 
|  | 99 | +$ curl \ | 
|  | 100 | +    --header "X-Vault-Token: ..." \ | 
|  | 101 | +    --request POST \ | 
|  | 102 | +    --data @payload.json \ | 
|  | 103 | +     ${VAULT_ADDR}/v1/sys/storage/raft/snapshot-auto/snapshot-load/${CONFIG_NAME} | 
|  | 104 | +
 | 
|  | 105 | +``` | 
|  | 106 | + | 
|  | 107 | +Refer to the [automated snapshot API](https://developer.hashicorp.com/vault/api-docs/system/storage/raftautosnapshots#load-a-snapshot-from-an-automated-snapshot-configuration)  | 
|  | 108 | +to learn more about automated snapshots. | 
|  | 109 | + | 
|  | 110 | +**Example of a manual upload:**  | 
|  | 111 | +```shell-session | 
|  | 112 | +$ curl \ | 
|  | 113 | +    --header "X-Vault-Token: ${VAULT_TOKEN}" \ | 
|  | 114 | +    --request POST \ | 
|  | 115 | +    --data-binary @raft.snap \ | 
|  | 116 | +    ${VAULT_ADDR}/v1/sys/storage/raft/snapshot-load | 
|  | 117 | +``` | 
|  | 118 | + | 
|  | 119 | +</Tab> | 
|  | 120 | +</Tabs> | 
|  | 121 | + | 
|  | 122 | + | 
|  | 123 | +## Snapshot overview | 
|  | 124 | + | 
|  | 125 | +1. The status of the snapshot and the expiration date is shown. This also allows  | 
|  | 126 | +to navigate to the snapshot details view. | 
|  | 127 | +     | 
|  | 128 | +2. Snapshot resources can be recovered or read from the snapshot overview page. | 
|  | 129 | +While in the root namespace, a namespace selector will be shown  | 
|  | 130 | +to allow for snapshot operations on resources in child namespaces as well. | 
|  | 131 | + | 
|  | 132 | +## Snapshot recovery | 
|  | 133 | + | 
|  | 134 | +<Tabs> | 
|  | 135 | +<Tab heading="Web UI" group="ui"> | 
|  | 136 | +    <Tip title="Permissions Required"> | 
|  | 137 | +        This requires recover permissions specific to the resource. | 
|  | 138 | +    </Tip> | 
|  | 139 | + | 
|  | 140 | +Upon a successful recovery operation, a success message with a link to the recovered resource will be shown. | 
|  | 141 | +     | 
|  | 142 | +In addition to recovering to the original resource path, recovering a copy to a new path is possible. The original resource will be unaffected. | 
|  | 143 | +     | 
|  | 144 | +</Tab> | 
|  | 145 | +<Tab heading="API call using cURL" group="api"> | 
|  | 146 | + | 
|  | 147 | +```shell-session | 
|  | 148 | +$ curl \ | 
|  | 149 | +    --header "X-Vault-Token: ..." \ | 
|  | 150 | +    --request POST \ | 
|  | 151 | +    https://127.0.0.1:8200/v1/cubbyhole/my-secret?recover_snapshot_id=2403d301-94f2-46a1-a39d-02be83e2831a | 
|  | 152 | +``` | 
|  | 153 | + | 
|  | 154 | +</Tab> | 
|  | 155 | +</Tabs> | 
|  | 156 | + | 
|  | 157 | +## Snapshot read | 
|  | 158 | + | 
|  | 159 | +<Tabs> | 
|  | 160 | +<Tab heading="Web UI" group="ui"> | 
|  | 161 | +    <Tip title="Permissions Required"> | 
|  | 162 | +        This requires read permissions specific to the resource. | 
|  | 163 | +    </Tip> | 
|  | 164 | + | 
|  | 165 | +Upon a successful read operation, the resource can be viewed as key value pairs or as JSON. | 
|  | 166 | + | 
|  | 167 | + | 
|  | 168 | + | 
|  | 169 | +</Tab> | 
|  | 170 | +<Tab heading="API call using cURL" group="api"> | 
|  | 171 | + | 
|  | 172 | +```shell-session | 
|  | 173 | +$ curl \ | 
|  | 174 | +    --header "X-Vault-Token: ..." \ | 
|  | 175 | +    http://127.0.0.1:8200/v1/sys/storage/raft/snapshot-load/2403d301-94f2-46a1-a39d-02be83e2831a | 
|  | 176 | +
 | 
|  | 177 | +``` | 
|  | 178 | + | 
|  | 179 | +</Tab> | 
|  | 180 | + | 
|  | 181 | +</Tabs> | 
|  | 182 | + | 
|  | 183 | +## Unload a snapshot | 
|  | 184 | + | 
|  | 185 | +<Tabs> | 
|  | 186 | +<Tab heading="Web UI" group="ui"> | 
|  | 187 | +    <Tip title="Permissions Required"> | 
|  | 188 | +        This requires snapshot management permissions. | 
|  | 189 | +    </Tip> | 
|  | 190 | + | 
|  | 191 | +1. Navigate to the details view | 
|  | 192 | +     | 
|  | 193 | +2. Unload the snapshot via the action menu | 
|  | 194 | +     | 
|  | 195 | +     | 
|  | 196 | +</Tab> | 
|  | 197 | +<Tab heading="API call using cURL" group="api"> | 
|  | 198 | + | 
|  | 199 | +```shell-session | 
|  | 200 | +$ curl \ | 
|  | 201 | +    --header "X-Vault-Token: ..." \ | 
|  | 202 | +    --request DELETE \ | 
|  | 203 | +    http://127.0.0.1:8200/v1/sys/storage/raft/snapshot-load/2403d301-94f2-46a1-a39d-02be83e2831a | 
|  | 204 | +
 | 
|  | 205 | +``` | 
|  | 206 | +</Tab> | 
|  | 207 | +</Tabs> | 
0 commit comments