Automasean

I've been using Fly.io to deploy my Elixir API and Postgres database.

These are my notes on helpful commands. Most of these are for debugging purposes.

To view the logs:

$ fly logs -a <app-name>

To deploy with no cache:

$ fly deploy -a <api-app-name> --remote-only --no-cache

To "rollback" a Fly deployment to a previous version:

$ fly releases --image -a <api-app-name>
$ fly deploy -a <api-app-name> -i registry.fly.io/your-app-name@sha256-hash

To connect to DB remotely:

$ fly ssh console -a <db-app-name>
$ psql <DATABASE_URL>

To restart the DB:

$ fly postgres restart -a <db-app-name>

To restart the API:

$ fly apps restart <api-app-name>

To restore a database snapshot:

$ fly volumes list -a <db-app-name>
$ fly volumes snapshots list <volume-id>
# scale down
$ fly scale count 0 -a <api-app-name>
#start back up
$ fly scale count 1 -a <api-app-name>
$ fly deploy --remote-only -a <api-app-name>
$ fly postgres detach <db-app-name>
$ fly postgres attach <db-backup-app-name>