You may not have seen this, but we launched a free volume tier a few weeks ago. Which means, free Postgres for side projects.
Our Postgres installations make it easy to move volume sizes. Here’s what you’d run assuming you have a single Postgres instance running and want to scale the volume down to 1GB:
- Add a new 1GB volume to your Postgres app:
fly volumes create pg_data --size 1 --region <your-pg-region> -a <pgname>
fly status -a <pgname>, note which instance is the leader and how many instances are running
- Add one more instance:
fly scale count 2 -a <pgname>(add a second instance)
- Wait a few minutes, then run
fly statusto make sure the new instance is in secondary state
fly volumes listto get the old volume ID
fly volumes delete <old-volume-id>
fly scale count 1 -a <pgname>: scale back to one instance
This works because all our Postgres apps are clusters, even if they’re only running one instance. When you scale up, it creates a replica. When you remove the old volume, it stops the primary, the new replica takes over, and you’re back down to one happy Postgres.
Be careful: under no circumstances should leave one instance of postgres running with 2+ volumes. If that VM crashes, it might come up on an empty disk. You should always have the exact number of volumes as
fly scale count <x> is set to.