Manage volume storage
Manage Fly Volumes using the fly volumes
command.
Fly Volumes are local persistent storage for Fly Machines. Learn how Fly Volumes work.
Note: fly volumes
is aliased to fly volume
and fly vol
.
Create a volume
Run:
fly vol create <my_volume_name>
Use the -r
option to set a region, or select a region when prompted.
For options, refer to the fly volumes create
docs or run fly vol create -h
.
To add a volume to your app, see Add volume storage.
Access a volume
You can access and write to a volume on a Machine just like a regular directory.
For Machines managed with Fly Launch, the destination
under [mounts]
in fly.toml
is the path for the mounted volumes.
For Machines managed individually, specify the mount path in the fly machine clone
command when you clone a Machine and add a volume.
Extend a volume
You can extend (increase) a volume’s size, but you can’t make a volume smaller.
Run
fly volumes list
and copy the ID of the volume to extend.Extend the volume size:
`fly vol extend <volume id> -s <new size in GB>`
(Optional) Check the new volume size in the Machine’s file system:
fly ssh console -s -C df
Example output:
? Select VM: [Use arrows to move, type to filter] > yyz: 4d891de2f66587 fdaa:0:3b99:a7b:ef:8cc4:dc49:2 withered-shadow-4027 Connecting to fdaa:0:3b99:a7b:ef:8cc4:dc49:2... complete Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 103068 0 103068 0% /dev /dev/vda 8191416 172752 7582852 3% / shm 113224 0 113224 0% /dev/shm tmpfs 113224 0 113224 0% /sys/fs/cgroup /dev/vdb 2043856 3072 1930400 1% /storage
In the preceding example, the volume is mounted under
/storage
and has been resized to from 1GB to 2GB. Thedf
command shows disk space in 1K blocks by default. Use the-h
flag to return a more human-readable format.
For options, refer to the fly volumes extend
docs or run fly vol extend -h
.
Create a copy of a volume (Fork a volume)
Create an exact copy of a volume, including its data. By default, we place the new volume on a separate physical host in the same region.
Important: After you fork a volume, the new volume is independent of the source volume. The new volume and the source volume do not continue to sync.
Run
fly volumes list
and copy the ID of the volume to fork.Fork the volume:
fly volumes fork <volume ID>
Example output:
ID: vol_grnoq5796wwj0dkv Name: my_volume_name App: my-app-name Region: yyz Zone: 511d Size GB: 3 Encrypted: true Created at: 12 Oct 23 18:57 UTC
(Optional) Attach the volume to a new Machine by cloning with
fly machine clone <machine id> -r <region code> --attach-volume <volume id>:<destination mount path>
or usefly scale count
to create a new Machine that picks up the unattached volume.
For options, refer to the fly volumes fork
docs or run fly vol fork -h
.
Restore a volume from a snapshot
We take daily snapshots and keep them for five days.
Run
fly volumes list
and copy ID of the volume to restore.List the volume’s snapshots:
fly vol snapshots <volume id>
Example output:
Snapshots ID SIZE CREATED AT vs_MgLAggLZkYx89fLy 17638389 1 hour ago vs_1KRgwpDqZ2ll5tx 17649006 1 day ago vs_nymJyYMwXpjxqTzJ 17677766 2 days ago vs_R3OPAz5jBqzogF16 17689473 3 days ago vs_pZlGZvq3gkAlAcaZ 17655830 4 days ago vs_A9k6age3bQov6twj 17631880 5 days ago
Restore 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 snapshots
docs or run fly vol snapshots -h
.
Clone a Machine with a volume
Clone a Machine with a volume to create a new Machine in the same region with an empty volume. Use the -r
option to clone the Machine into a different region.
Run
fly status
and copy the Machine ID of the Machine to clone.Clone the Machine:
fly m clone <machine id>
List volumes to check the result:
fly volumes list
Example output showing two volumes with attached Machines:
ID STATE NAME SIZE REGION ZONE ENCRYPTED ATTACHED VM CREATED AT vol_ez1nvxkwl3jrmxl7 created data 1GB lhr 4de2 true 91851edb6ee983 39 seconds ago vol_zmjnv8m81p5rywgx created data 1GB lhr b6a7 true 5683606c41098e 7 minutes ago
Note: fly machine clone
doesn’t write data into the new volume.
For options, refer to the fly machine clone
docs or run fly m clone -h
.
Destroy a volume
Warning: When you destroy a volume, you permanently delete all its data.
Run
fly volumes list
and copy ID of volume to destroy.Destroy the volume:
fly vol destroy <volume id>
For options, refer to the fly vol destroy
docs or run fly vol destroy -h
.