Treasury|Treasury Docs

Migrate from Fly to Treasury

This guide walks you through the steps needed to seamlessly migrate your app and data from Fly.io to Treasury. This process is straightforward and typically takes an average of 5 - 20 minutes, depending on the size of your database and app complexity.

TL;DR: Quick Migration Steps

  • Set up new app on Treasury
  • Export data from Fly.io and Import into Treasury DB
  • Deploy app (including auto-migration of app config & variables)

We provide everything Fly.io offers and more! Check out the comparison guide to see the differences and make an informed choice.

Why take Treasury's word for it? Experience the Treasury advantage yourself, give it a spin today!

Migration steps

In this guide, we will migrate a Go (Gin) app with a Postgres database from Fly.io to Treasury. While we are using this app as an example, the process applies to any app, making it easy to transition your projects smoothly.

Here’s the link to the app.

1. Set up a Treasury project

Navigate to Treasury's Project Creation Page.

Select the Deploy from GitHub Repo option and connect your repository. If your Treasury account isn’t linked to GitHub yet, you’ll be prompted to do so.

Treasury new project

2. Deploy the app

Treasury auto-imports all the build configurations, deploy commands, environment variables from your Fly.io app repo. No manual setup needed.

If the environment variables are missing, you can easily add them manually by following these steps:

Adding environment variables on Treasury:

  1. Navigate to the Variables section of your service.
  2. Switch to the Raw Editor and paste the copied environment variables.
  3. Deploy the changes to apply the configuration.

Variables imported automatically from fly.toml into Treasury service

Treasury will deploy the Gin app as a service, as shown in the image above. You can monitor the service building and deploying in the Project Canvas.

Serverless (App Sleep) activated: In this Fly.io app, the HTTP service is configured with auto_stop_machines='stop' and auto_start_machines=true, enabling automatic stopping and restarting of machines. On Treasury import, we automatically enable this setting to effortlessly optimize resource usage.

App sleep activated to optimize resource usage and spend

3. Database migration

Treasury supports a variety of databases, including PostgreSQL, MongoDB, MySQL, and Redis, allowing you to deploy the one that best fits your application needs. We also support many more via the templates marketplace.

If you're migrating data to Treasury from Fly, you can follow these steps:

  1. Provision a new database by right clicking on the dashboard canvas and selecting Postgres.
  2. Export your data from Flyio
    • Use flyctl to connect to your Flyio Postgres instance
      • fly postgres connect -a <postgres-app-name>
    • Use pg_dump to export your database
      • pg_dump -Fc --no-acl --no-owner -h localhost -p 5432 -U <your-db-username> -d <your-db-name> -f flyio_db_backup.dump
    • Use pg_restore to connect to your Treasury database and restore the data from the dump.
      • pg_restore -U <username> -h <host> -p <port> -W -F t -d <db_name> <dump_file_name>

For detailed instructions, check out this comprehensive tutorial on migrating PostgreSQL data between services.

Once the migration is complete, update the DATABASE_URL environment variable in your Treasury app to point to the new PostgreSQL database and redeploy.

4. Replicas & multi-region deployments

In this Fly.io app, the setting min_machines_running=2 ensures that at least two instances of the service remain active. On Treasury import, we automatically translate this configuration to ensure that two service instances are running without any extra setup.

Replicas

If your app needs to use multi-region deployments, you can leverage Treasury’s multi-region replicas.

Enable this in the Settings section of your Treasury service to keep your app close to users worldwide.

Note: Multi-region replicas is currently available to Pro users.

And that’s it. That’s all you need to migrate your app from Flyio to Treasury.