Restoring a local database on fly.io postgres instance

Hello, I’ve just started playing around with Fly.io and I’m really liking it so far, I’ve migrated a phoenix app and would also like to restore my development database to production, is this possible?

Cheers

Hey there,

and would also like to restore my development database to production,

Could you elaborate on this a bit more?

Of course Shaun,
So I’ve been developing an application locally (including adding data to my database), and rather than having to add that data all again, was wondering if i can restore a pg_dump of the local data to the postgres instance i created using the fly postgres create command.
I guess on a more general level I’m wondering if it’s possible to restore a backed up database to a fly postgres instance, including backing up a fly postgres instance, and restoring it

I guess on a more general level I’m wondering if it’s possible to restore a backed up database to a fly postgres instance

Yep! As long as you’ve set up a Wireguard tunnel, this will be easy to accomplish. If you haven’t yet, here’s a step-by-step guide: Private Networking

Once you’ve provisioned your Postgres via fly postgres create, you’ll be provided with a connection string that you can use to connect. From here, it should just be a matter of issuing a pg_restore.

Something like this should work:

pg_restore -v -d [FLY_POSTGRES_URI] < [path-to-dump-file]

including backing up a fly postgres instance, and restoring it

Here’s some information going over the PG restore process: Multi-region PostgreSQL

Let me know if you have any other questions!

1 Like

Awesome Shaun, I’ll give that a shot, thanks for the quick response