I’m in a similar situation. Can you give the command you used? And did you do it from the command line or SSH? And I assume you downloaded to your local machine. I barely understand all of this but have been using Heroku for several Rails/Postgres apps and am looking for a less expensive option. Two of the apps are being developed on my local Mac and the database resides there too. I upload the database and changes to the app periodically. But some of the fly command line commands are not clear to me. Heroku kept the database and app separate whereas is seems to me fly makes that less clear.
One example of my confusion. Your OP had pg_dump --no-owner -C -d $HEROKU_DATABASE_URL | psql -d $DATABASE_URL. How can I see the the $ variables are and is this command going to Heroku and uploading to Fly?
Type the password when prompted. To get the credentials from Heroku go to your application settings and ‘Reveal Config Vars’. You’ll find the DATABASE_URL, which is in the format postgres://$USER:$PASSWORD@$HOST:$PORT/$DATABASE
Find the database connection URL for your Fly PG database, using the following commands:
fly ssh console
Set up Wiregaurd on your local machine so that you can access your Fly database. Click this link for the tutorial.
Restore the database using the following command:
pg_restore -v -d [FLY_POSTGRES_URL] < latest.dump
Then you should be done. One thing to note is to make sure you do all of this in your project directory in the terminal.
When I substitute that for [FLY_POSTGRES_URL] I get pg_restore: error: could not translate host name "top2.nearest.of.late-sun-7751-db.internal" to address: nodename nor servname provided, or not known
I also tried psql [database_name} < db_dump.sql and got a lot of errors. Heroku and localhost is fine with the database. The error had to dot with ‘duplicate key value’ and ‘“ar_internal_metadata” already exists’ among others.
When I installed WireGuard the responses didn’t match what was shown on the link. I accepted a default and it finished.
That sounds like a WireGuard error, what steps did you take to set it up?
You need to do fly wireguard create, choose which organisation to set it to (most likely your personal one, this will be autoselected if that’s the only one you have). Then, enter the name of the configuration file as ‘basic.conf’.
When you install the WireGuard client from the Mac app store, it should open up and give you the option to import a a configuration file. Select the one you just created.
You can test if the Wireguard connection has worked by installing dig and using the following command:
brew install bind
then, when that has installed:
dig +noall +answer _apps.internal txt
Your app should appear on the list that this shows.
When this is set up, using the following command should work:
pg_restore -v -d [FLY_POSTGRES_URL] < latest.dump failed for me as well. I don’t think you should run it from the local directory where your app is located. I had my dump file in Downloads folder, so I ran it from there and it failed with:
/bin/sh: 2: cannot open my_dump_file.dump: No such file
as if FLY supposed me to have this dump file present at the remote host.
Thanks a lot for sharing!
I followed step-by-step but the last command pg_restore -U postgres -h localhost -p 15432 -d foobar < latest.dump (no ; at the end) had no effects. After checking the database tables, no data was restored at all. I ran the same dump recently on a local DB and it worked. Any clues? Thank you.