> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage volume snapshots

A snapshot is a point-in-time copy of a volume's data. We automatically take daily snapshots of all Fly Volumes. We store snapshots for 5 days by default, but you can set volume snapshot retention from 1 to 60 days.

<Note>
  If the data stored on your volume updates frequently, then you should have other methods to back up or replicate your data in addition to daily snapshots. If you only have a single copy of your data on a single volume, and the host fails, then any data stored between the time when the snapshot was taken and the time when the failure occurred will be lost.
</Note>

You can use a volume snapshot to [restore the data into a new volume](#restore-a-deleted-volume). You can even use the same process to [restore data from a deleted volume](/volumes/volume-manage#restore-a-deleted-volume).

## Set or change the snapshot retention period

Snapshot retention is the length of time (in days) that we store a volume snapshot. The default is 5 days.

Set snapshot retention when you create a volume:

```
fly volumes create <my_volume_name> --snapshot-retention <retention in days>
```

You can also update the snapshot retention for a volume. The new retention period is applied to new snapshots; it won't affect existing snapshots.

Update snapshot retention for an existing volume:

```
fly volumes update <volume id> --snapshot-retention <retention in days>
```

For Fly Launch apps, you can add snapshot retention to the `[mounts]` section of your app's `fly.toml` file. Any new Fly Volumes `fly deploy` creates will have the new retention period. This example sets the snapshot retention period to 14 days:

```toml theme={null}
[mounts]
source = "myapp_data"
destination = "/data"
snapshot_retention = 14
```

## Create a volume snapshot

We automatically take daily snapshots of your volume and keep them for 5 days by default. You can also create a snapshot of a volume on demand:

1. Run `fly volumes list` and copy the ID of the volume to create a snapshot from.

2. Create a snapshot of the volume:

   <CodeGroup>
     ```bash cmd theme={null}
     fly volumes snapshots create <volume id>
     ```

     ```out out theme={null}
     Scheduled to snapshot volume <volume id>
     ```
   </CodeGroup>

   The snapshot might take a few seconds or longer to complete, depending on the volume size.

3. List the volume's snapshots:

   ```bash theme={null}
   fly volumes snapshots list <volume id>
   ```

   Example output:

   ```out theme={null}
   Snapshots
   ID                           STATUS   STORED SIZE  VOL SIZE  CREATED AT  RETENTION DAYS
   vs_A1b2C3d4E5f6G7h8I9j0K1l2  created      2.0 GiB    10 GiB  5 days ago               5
   vs_M3n4O5p6Q7r8S9t0U1v2W3x4  created      187 MiB    10 GiB  4 days ago               5
   vs_Y5z6A7b8C9d0E1f2G3h4I5j6  created       45 MiB    10 GiB  3 days ago               5
   vs_K7l8M9n0O1p2Q3r4S5t6U7v8  created      106 MiB    10 GiB  2 days ago               5
   vs_O9jqw997yvOuzyg1NVmmmjxh  running          0 B    10 GiB
   ```

The state of the new snapshot will go from `waiting` to `running` to `created`.

For options, refer to the [`fly volumes snapshots` docs](/flyctl/cmd/fly_volumes_snapshots) or run `fly volumes snapshots --help`.

## Restore a volume from a snapshot

The procedure to restore data from a deleted volume is very similar, see [Restore a deleted volume](/volumes/volume-manage#restore-a-deleted-volume).

Restore the data from a volume by creating a new volume from a snapshot:

1. Run `fly volumes list` and copy the ID of the volume to restore.

2. List the volume's snapshots:

   ```bash theme={null}
   fly volumes snapshots list <volume id>
   ```

   Example output:

   ```out theme={null}
   Snapshots
   ID                           STATUS   STORED SIZE  VOL SIZE  CREATED AT  RETENTION DAYS
   vs_A1b2C3d4E5f6G7h8I9j0K1l2  created      2.0 GiB    10 GiB  5 days ago               5
   vs_M3n4O5p6Q7r8S9t0U1v2W3x4  created      187 MiB    10 GiB  4 days ago               5
   vs_Y5z6A7b8C9d0E1f2G3h4I5j6  created       45 MiB    10 GiB  3 days ago               5
   vs_K7l8M9n0O1p2Q3r4S5t6U7v8  created      106 MiB    10 GiB  2 days ago               5
   vs_W9x0Y1z2A3b4C5d6E7f8G9h0  created       73 MiB    10 GiB  1 day ago                5
   ```

3. Restore data from the volume snapshot into a new volume of equal or greater size:

   ```bash theme={null}
   fly volumes create <volume name> --snapshot-id <snapshot id> -s <volume size in GB>
   ```

   Example output:

   ```out theme={null}
   ? Select region: Sydney, Australia (syd)
           ID: vol_mjn924o9l3q403lq
         Name: pg_data
         App: my-app-name
       Region: syd
         Zone: 180d
     Size GB: 3
   Encrypted: true
   Created at: 02 Aug 22 21:27 UTC
   ```

For options, refer to the [`fly volumes create` docs](/flyctl/cmd/fly_volumes_create) or run `fly volumes create --help`.

## Create a Machine with a volume from a snapshot

Create the volume and the Machine in one command:

```bash theme={null}
fly scale count --with-new-volumes --from-snapshot <snapshot id> 1
```

`--with-new-volumes` creates a new volume instead of reusing an existing one. `--from-snapshot` populates that volume from the snapshot. The trailing `1` is the Machine count.

For options, refer to the [`fly scale count` docs](/flyctl/cmd/fly_scale_count) or run `fly scale count --help`.

## List snapshots and their stored sizes

Snapshots for each volume are stored incrementally, so only data that has changed since the previously stored snapshot consumes additional storage. The total stored size of the snapshots is used for [Volume Snapshot billing](/about/billing#volume-snapshot-billing).

1. Run `fly volumes list` and copy the ID of the volume.

2. List the volume's snapshots:

   ```bash theme={null}
   fly volumes snapshots list <volume id>
   ```

   Example output:

   ```out theme={null}
   Snapshots
   ID                           STATUS   STORED SIZE  VOL SIZE  CREATED AT  RETENTION DAYS
   vs_A1b2C3d4E5f6G7h8I9j0K1l2  created      2.0 GiB    10 GiB  5 days ago               5
   vs_M3n4O5p6Q7r8S9t0U1v2W3x4  created      187 MiB    10 GiB  4 days ago               5
   vs_Y5z6A7b8C9d0E1f2G3h4I5j6  created       45 MiB    10 GiB  3 days ago               5
   vs_K7l8M9n0O1p2Q3r4S5t6U7v8  created      106 MiB    10 GiB  2 days ago               5
   vs_W9x0Y1z2A3b4C5d6E7f8G9h0  created       73 MiB    10 GiB  1 day ago                5

   Total stored size: 2.5 GiB
   ```

## Disable automatic daily snapshots

Automatic daily snapshots are enabled by default. To disable automatic snapshots, use the `--scheduled-snapshots=false` flag. Snapshots of encrypted volumes (defaults to `true`) are likewise encrypted at rest.

Disable automatic snapshots when you create a volume:

```
fly volumes create <my_volume_name> --scheduled-snapshots=false
```

Disable automatic snapshots for an existing volume:

```
fly volumes update <volume id> --scheduled-snapshots=false
```

Disabling automatic snapshots will not remove any existing snapshots for the volume; snapshots are only removed at the end of their retention periods.

For Fly Launch apps, you can disable automatic snapshots in the `[mounts]` section of your app's `fly.toml` file. Any new Fly Volumes `fly deploy` creates will have automatic snapshots disabled:

```toml theme={null}
[mounts]
source = "myapp_cache"
destination = "/cache"
scheduled_snapshots = false
```

## Related topics

* [Fly Volumes overview](/volumes/overview)
* [Create and manage volumes](/volumes/volume-manage)
* [Add volume storage to a Fly Launch app](/launch/volume-storage)
* [Scale an app with volumes](/launch/scale-count#scale-an-app-with-volumes)
