pg_dump: server version: 13.7 (Ubuntu 13.7-1.pgdg20.04+1); pg_dump version: 11.17 (Debian 11.17-0+deb10u1)
pg_dump: aborting because of server version mismatch
Is there any way I can fix this? Any help would be appreciated.
I would maybe try running the command on your local machine and you should ensure that your local Postgres version matches the version you’re restoring into.
My local Postgres is version 14.5, but I am still getting the same error. I am running the command through SSH into my Fly app, so is there a way I can upgrade the pg_dump command?
Thanks for the reply Shaun, I’m now getting an error when trying to deploy this app!
Sending build context to Docker daemon 31.55kB
Error failed to fetch an image or build from source: error building: Error response from daemon: invalid reference format
Again, any help on this would be hugely appreciated.
Thanks for the help Shaun, I managed to transfer my data across. I downloaded a .dump of my Heroku database and then used pg_restore to upload it to my Fly database.
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
echo $DATABASE_URL
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_dump: error: server version: 14.5 (Ubuntu 14.5-2.pgdg20.04+2); pg_dump version: 13.8 (Debian 13.8-0+deb11u1)
pg_dump: error: aborting because of server version mismatch
I just added postgres-client v14 to my Dockerfile and all OK
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.