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.
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.
You can use a volume snapshot to restore the data into a new volume. You can even use the same process to restore data from 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:
[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:
Run
fly volumes list
and copy the ID of the volume to create a snapshot from.Create a snapshot of the volume:
fly volumes snapshots create <volume id>
Scheduled to snapshot volume <volume id>
The snapshot might take a few seconds or longer to complete, depending on the volume size.
List the volume’s snapshots:
fly volumes snapshots list <volume id>
Example output:
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 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.
Restore the data from a volume by creating a new volume from a snapshot:
Run
fly volumes list
and copy the ID of the volume to restore.List the volume’s snapshots:
fly volumes snapshots list <volume id>
Example output:
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
Restore data from the volume snapshot into a new volume of equal or greater size:
fly volumes create <volume name> --snapshot-id <snapshot id> -s <volume size in GB>
Example output:
? 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 or run fly volumes create --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.
Run
fly volumes list
and copy the ID of the volume.List the volume’s snapshots:
fly volumes snapshots list <volume id>
Example output:
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.
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:
[mounts]
source = "myapp_cache"
destination = "/cache"
scheduled_snapshots = false