Recovering Data from Orphaned Fly.io Volumes

2 min read

After a hardware failure on Fly.io triggered a migration to new hardware, I encountered an issue where the new machine didn't mount to the old volume but instead created a new one. Despite attempts to mount the old volume, persistent errors prevented me from attaching it to the application. This guide outlines the steps I took to retrieve data from the orphaned volume, which may prove useful for others facing similar challenges.

Setting Up

  1. Create a new directory and add a fly.toml file with your app name:
app = "<your_app_name>"

This step simplifies subsequent commands by eliminating the need to specify the app name repeatedly.

  1. List the volumes associated with your app to identify the orphaned volume's ID:
fly vol list

Create a minimal Dockerfile:

FROM ubuntu:22.04

Accessing the Volume

Start a barebones machine mounted to the orphaned volume:

fly machine run . --volume <vol_id>:data --region <region> --shell

This command creates and runs a machine, mounts the volume, and connects you via SSH.

Retrieving Data

You have two main options for retrieving data:

Option 1: Using SCP

If you have SCP access, you can directly transfer files to another machine.

Option 2: Using SFTP

For those preferring an alternative:

  1. List files on the remote volume:
 fly ssh sftp find /data
  1. Download a specific file:
fly ssh sftp get /data/<path_to_file>
  1. For directories, consider compressing them on the server before transfer:
# On the remote machine
tar -czf /data/archive.tar.gz /data/your_directory

# Then on your local machine
fly ssh sftp get /data/archive.tar.gz

Cleanup

Exit the shell to terminate the temporary machine.