The following guide shows you how to [revert](https://docs.cloud.google.com/filestore/docs/reference/rest/v1/projects.locations.instances/revert.md.txt)
an instance, specifically a single file share within an instance, to a prior
snapshot state.

## Should you use the `revert` operation?

The revert snapshot feature is an irreversible operation, both to the live file
system and to the newer snapshots in the chain. Use the revert feature carefully.
For a more detailed explanation, see [Revert to a snapshot state](https://docs.cloud.google.com/filestore/docs/snapshots.md.txt#revert-to-snapshot).

All data written after the creation of the target snapshot is deleted
at the beginning of the revert process and cannot be recovered. All snapshots
that are newer than the target snapshot are also deleted. For example,
`snapshot1`, `snapshot2`, and `snapshot3` are created sequentially. Reverting
the instance to the state captured in `snapshot2` means that all data written
after `snapshot2`, as well as all snapshots taken after the creation of
`snapshot2`, are deleted in the revert process.

While a revert operation can take up to two minutes to complete, cleanup of the
deleted data can take between six hours to ten days, depending on the number
of files involved. You must wait for the revert operation to complete before
starting another revert operation.

Only instances with a single share can revert to a snapshot state. The revert
snapshot feature can't be combined with [Filestore multishares for GKE](https://docs.cloud.google.com/filestore/docs/multishares.md.txt).
For more information, see [Snapshot feature limitations](https://docs.cloud.google.com/filestore/docs/snapshots.md.txt#feature_limitations)
or the [`gcloud filestore instances revert`](https://docs.cloud.google.com/sdk/gcloud/reference/filestore/instances/revert)
page.

## Use gcloud CLI to revert a file share to a previous snapshot

### gcloud CLI

To revert a file share to the state captured in a snapshot:

1. Unmount the file share from clients:

   ```bash
   sudo umount mount-point-directory
   ```
2. Revert the file share to a snapshot state using the [`instances revert`](https://docs.cloud.google.com/sdk/gcloud/reference/filestore/instances/revert)
   command:

   ```bash
   gcloud filestore instances revert INSTANCE_ID \
       --target-snapshot=SNAPSHOT_ID \
       --location=LOCATION
   ```

   Replace the following:
   - <var translate="no">INSTANCE_ID</var> with the name of the instance where you want to apply the `revert` operation. For example, `my-instance-1`.
   - <var translate="no">SNAPSHOT_ID</var> with the name of the snapshot you want to use for the `revert` operation. For example, `my-snapshot-3`.
   - <var translate="no">LOCATION</var> with the location of the instance. For example, `us-central1`.

You must wait for the revert operation to complete before you can start
another revert operation for the instance. Revert operations can take up to
two minutes. However, the data cleanup and space reclamation process can take
between six hours to ten days to complete. During this process, the reclaimed
space becomes available gradually while the cleanup operation finishes
and all reclaimed space is available. For more information, see
[Snapshot limitations](https://docs.cloud.google.com/filestore/docs/snapshots.md.txt#feature-limitations).

## What's next

- [Snapshots overview](https://docs.cloud.google.com/filestore/docs/snapshots.md.txt)
- [Restore a file from a snapshot](https://docs.cloud.google.com/filestore/docs/restore-file.md.txt)
- [Schedule Filestore enterprise snapshots](https://docs.cloud.google.com/filestore/docs/schedule-filestore-enterprise-snapshots.md.txt)
- [Backups overview](https://docs.cloud.google.com/filestore/docs/backups.md.txt)