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.

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

  2. Extend the volume size:

    `fly vol extend <volume id> -s <new size in GB>`
    
  3. (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. The df 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. Use the --region option to fork the volume into another 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.

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

  2. Fork the volume:

    fly volumes fork <volume ID> --region <region>
    

    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
    
  3. (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 use fly 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.

Create a volume snapshot

We take daily snapshots of your volume and keep them for five days. 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:

    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.

  3. List the volume’s snapshots:

    fly vol snapshots list <volume id>
    

    Example output:

    Snapshots
    ID                              STATUS  SIZE        CREATED AT
    vs_yAJylAAN83ZFna0A2yRA3J       created 76082175    3 hours ago
    vs_3NlZ9NNmpvoSP4yv3Om1gPm      created 76082175    1 day ago
    vs_Y49bw44Z6OocN8j4oXq6ww       created 76082175    2 days ago
    vs_gwMAXwwLjOVu1vPQVMN2w3N      created 76082175    3 days ago
    vs_Ql8xbllZOYDSmlKB0jxYVpg      created 76082175    4 days ago
    vs_plNk4llRGexSL22MOJYRpp       created 76082175    5 days ago
    vs_O9jqw997yvOuzyg1NVmmmjxhJ    running 0
    

The state of the new snapshot will go from waiting to running to created. Once the snapshot is created, you can use it to restore the volume’s data if needed.

Restore a volume from a snapshot

We take daily snapshots of your volume and keep them for five days. You can also create a snapshot on demand.

You can 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:

    fly vol snapshots list <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
    
  3. 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.

  1. Run fly status and copy the Machine ID of the Machine to clone.

  2. Clone the Machine:

    fly m clone <machine id>
    
  3. 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.

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

  2. Destroy the volume:

fly vol destroy <volume id>

For options, refer to the fly vol destroy docs or run fly vol destroy -h.