I am using archlinux and trying to upgrade postgresql from 11 to 13. I am following https://wiki.archlinux.org/title/PostgreSQL#Upgrading_PostgreSQL
I am stuck up at
[postgres]$ pg_upgrade -b /opt/pgsql-11/bin -B /usr/bin -d /var/lib/postgres/olddata -D /var/lib/postgres/data
it says /opt/pgsql-11/bin does not exist
How to get around this
The postgresql-old-upgrade only supports the previous version of PostgreSQL (12 currently). It does not handle jumping multiple versions.
For those wishing to use pg_upgrade, a postgresql-old-upgrade package is available that will always run one major version behind the real PostgreSQL package.
You have multiple solutions :
Install manually or make an AUR package for postgresql-12-upgrade
Rollback your system (or at least postgresql and postgresql-old-upgrade) using the archlinux archive.
Dump your old database to a SQL file and import it in the new database.
I have 2 different major versions of postgres 9 and 10 installed on rhel.
Latest situation after attempts of updating psql package:
I have psql 9.2.24 installed on rhel 7.6 while the server version is 10.7.
I had earlier issues with my yum repo which got corrupted and later on, i recovered/fixed it with the help of following command mentioned at here (You can get idea of what my problem was initially with corrupt yum repo)
echo 7 > /etc/yum/vars/releasever
I checked my update-alternatives at here
and it is correctly referring to the psql at 10.7 directory but still I am seeing the psql old version number while connecting to existing database.
Following was the steps i followed to update the psql package:
All databases were kept running.
yum install postgresql10.x86_64
Command mentioned in point 2, installed/upgraded whole lot of packages on machine as the yum repo was corrupted . one of the key statements in this upgrade concerning to postgres was
postgresql10 x86_64 10.7-2PGDG.rhel7 pgdg10 1.6M
Please note, I have not yet restarted any of the instance running during/before/after above update and somehow believe it has something related to the fact that until I restart(stop existing instances and start them again) all running instances of psql/db's , psql changes will not start reflecting but that is just my assumption. Could someone please help what i understood/did wrong in this upgrade process.
Nothing except above has been changed/upgraded in terms of psql/postgres. Still I have both installations of postgres: 9 and 10.
I did this fix few months back and I forgot that. Something similar with better answers are at here So all credits goes to answer posters there. But here is what I did to solve it:-
Restarting already running postgres instances did not help.
I checked which psql showed me one of the psql at /usr/bin . It was some 9 months old so definitely it was not something got installed with my yum postgres... install step mentioned in my question which made me realize that new package installation will not override it straightaway.
I tried using
update-alternatives --config pgsql-psql but got the same error as mentioned on the above SO answer:
/usr/bin/psql exists and it is not a symlink
key clue on this page is in the comment from #Alexander Gorg that ln command will not override the existing link , it needs to be removed manually. I thought of removing the symlink but then end up renaming the psql at /usr/bin to psql_org.
Indeed i issued ln command during this process.
Now i issued the update-alternatives command and restarted one of the instances. Correct psql was now there.
Above indeed helped fixing psql version but still other utilities pg_basebackup and others were referring to older version. I believe better approach would have been to remove the old postgresql installation. I tried to list existing postgresql version with
yum list installed | grep postgres
only shows that
postgresql10*
packages are there and I remember I have already removed older postgres version with
yum erase postgres... so not sure what to remove.
Temporarily I have further solved issued by renaming other utilities in /usr/bin and then updating their alternatives.
I just upgraded to postgres 10.2 on mac os which matches 10.2 on heroku. I'm trying to download a copy of the database and restore it locally. Before the upgrade the restore would work fine.
I run
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d database_name backup.dump
but I am getting this error:
pg_restore: [archiver] unsupported version (1.13) in file header
The database appears to be working OK. It's a rails app and I upgraded the pg gems. I can run rake db:create and db:migrate just fine.
You need to upgrade your local postgres to get the last security patch from the 2018-03-01, like Heroku did the 1st march. You need one of the last releases 10.3, 9.6.8, 9.5.12, 9.4.17, and 9.3.22.
The security patch can be found here https://www.postgresql.org/about/news/1834/.
It seems the patch modified pg_dump, that's probably why we can't use pg_restore anymore without that patch for the dump of Heroku (with the patch applied).
I ran into this same issue today, I don't know if something changed on Heroku's side, because locally I'm running 9.6 but my database on Heroku is 9.4, so it didn't seem to be about the version point difference (it was working until today.)
If you're using the Postgres.app (https://postgresapp.com/) on a Mac make sure you're running v2.1.3 (as of this writing that is the newest version). When you upgrade the Postgres.app you get the newest patch release of Postgres, (which is likely causing the mismatch you're currently experiencing - Heroku has upgraded for the latest security patch, and your local machine may not have it).
I had to upgrade Postgres.app from 2.1.0 to 2.1.3 and it solved the problem.
First time I've had this issue, here's how I restored the Heroku Database to my Local:
$ rails db:drop
$ heroku pg:pull DATABASE_URL <insert local DB name> --app <app-name>
Since yesterday (03/01/2018) we also had problems restoring a backup from Heroku running on PostgreSQL 9.5:
pg_restore: [archiver] unsupported version (1.13) in file header
Upgrading our PostgreSQL version from 9.5.11 to 9.5.12 fixed the issue.
For those who are trying to upgrade postgresql in Ubuntu without success (like Johan's commented above), try using the PostgreSQL apt repository, as stated in the official PostgreSQL download instructions: https://www.postgresql.org/download/linux/ubuntu/
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
The fix for me involved both updating my Postgres.app and updating my local homebrew PostgreSQL.
Update my Postgres.app via Canuk's answer:
Open Postgres.app > Check for updates...
Update my local homebrew PostgreSQL via gerry3's comment on the accepted answer:
brew upgrade postgresql brew postgresql-upgrade-database
Had this problem on Windows using pgAdmin 3.
Upgrading from pgAdmin 3 to pgAdmin 4 solved the problem for me.
If you are using a third-party tool, such as PgAdmin, to restore the
provided dump file, the restore may not succeed even with the
installed Postgres version being up to date. This is due to
third-party tools often bundling their own versions of the pg_restore
binary, that may not be up to date.
https://help.heroku.com/YNH1ZJUS/why-am-i-getting-pg_restore-archiver-unsupported-version-1-13-in-file-header-error-with-pg_restore
I don't recommend upgrading your DB to a new major version locally (do apply security patches) just to fix this as you want that to match whatever version you have in production.
This fixed it on Ubuntu 16.04, restoring from a Heroku database.
First, ensure you have the postgresql repo as diego mentioned. Then install the upgraded client.
sudo apt-get update && sudo apt-get install postgresql-client-10
If you are Ubuntu 17.04 or 17.10, note that the PostgreSQL's zesty repo does not have the updated client's you need. You will want to use the xenial Postgres repo instead.
I encountered this problem on pgadmin III and was able to fix it through switching the binaries location:
File menu > Options > Binary Paths, then changed "PG bin path" to postgresql/9.x/bin instead of ProgramFiles/pgadmin. Restore worked fine afterwards.
Here is how I resolved the issue on Ubuntu(16.04 LTS) where pg_restore/pg_dump gave me an older version, from psql
$ pg_restore --version
pg_restore (PostgreSQL) 9.4.8
$ psql --version
psql (PostgreSQL) 9.5.14
The issue is that I have multiple pg versions installed, and pg_restore was pointing to the earlier version
$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.4 main 5432 online postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log
9.5 main 5433 online postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
The fix is to create a ~/.postgresqlrc file pointing to the correct version
$ cat ~/.postgresqlrc
9.5 main *
Once this was done, pg_restore points to the correct version, and the command goes through
Details given here: https://serverfault.com/questions/610777/wrong-version-of-pg-dump-on-ubuntu
You're using an old version of pg_restore binary that doesn't support restoring the provided dump file. Please make sure that you use the latest Postgres version, which must be higher than the following release: https://www.postgresql.org/about/news/1834/ (10.3, 9.6.8, 9.5.12, 9.4.17, and 9.3.22).
You can check the pg_restore version you're using by running pg_restore --version.
If you are using a third-party tool, such as PgAdmin, to restore the provided dump file, the restore may not succeed even with the installed Postgres version being up to date. This is due to third-party tools often bundling their own versions of the pg_restore binary, that may not be up to date.
I was encountering the same error. I updated to postgresql 10.3 locally, and that fixed the problem for me.
For Windows:
Open Command Prompt (cmd), then go to location C:\Program Files\PostgreSQL\9.6\bin and run these commands:
pg_restore -U username -d dbname -1 filename.dump
pg_restore -U postgres -d app -1 G:\app09-07-2019.backup
Hope it will help you
I ran in the same issue 10 minutes ago, and found out about this thread from 2005:
https://www.postgresql.org/message-id/1106163722.780395.266900%40z14g2000cwz.googlegroups.com
Basically the guy is saying the dump file is corrupt.
I am new to Linux and I found it really difficult to install older version of postgresql (along with postgis). I have uninstalled everything I could find connected to postgresql in aptidude. As only the newest version is available through apt-get install, I have went through several tutorials how to get 9.1 installed.
Example: https://wiki.postgresql.org/wiki/Apt (with 9.1 at the end, not 9.3)
After I was done with this tutorial, pgAdmin III is still showing 9.3 as version.
What's the correct way to dump 9.3 and install 9.1 as well as postgis 1.5?
I am using Mint 17
Okay. First off it is perfectly fine to run multiple versions of postgresql alongside one another. You can have more than one cluster on a box, and each cluster can run different versions. The debian pacakges are very well designed to make this easy to do.
However since you've indicated you're a newby to linux/postgresql it's probably best to get 9.3 completely cleaned from your system to avoid frustrating hiccups which will take you a long time to figure out.
To do this you need to:
Purge all postgresql 9.3 packages from dpkg
Manually delete any 9.3 data and configuration for 9.3 cluster
Make sure you've created a 9.1 cluster
Step 1 – purge DPKG
DPKG manages the packages on your system. APT acts as a mechanism for getting packages to install. A lot of DPKG functionality is available through apt, but some things are just easier on dpkg. In your comments you've shown that DPKG is still showing remnants of 9.3. When you uninstall a package some parts of it may hang around (such as configuration files). You can remove multiple packages in one command. To get rid of these completely you can tell dpkg to purge them dpkg --purge <package name>. You can remove multiple packages in one command and it's best to do so.
dpkg --list will list everything on your system. dpkg --list | grep postgresql searches this list for postgresql.
Step 2 – Manually delete data and configuration from the old 9.3 cluster.
When you first install postgresql it creates a cluster for you; no questions asked. This trips up a lot of new users because they neither knew that it happened nor how to replace it. Now that 9.3 is uninstalled you can go ahead and simply delete the configuration and data:
If there was anything you wanted to keep in the installed 9.3 database DO NOT run the following commands
sudo rm -rf /etc/postgresql/9.3 Removes the configuration.
sudo rm -rf /var/lib/postgresql/9.3 Removes the data.
Step 3 – Create a new cluster
You've indicated in comments that postgresql 9.1 is installed. Before you run this command it's worth reading the manual. man pg_createcluster.
sudo pg_createcluster 9.1 <think up a name>
Now you should be able to start up postgresql sudo service postgresql start
Edit
If pg_config is still listing the incorrect version then... this can be a result of remnants of 9.3 still left on your system. This may not be a problem. To allow multiple versions to run along side one another pg_config is a wrapper script which searches for the latest (highest version) of /usr/lib/postgresql/*/bin/pg_config. So what you're seeing is the result of running /usr/lib/postgresql/9.3/bin/pg_config. If 9.3 is completely cleaned from your system then /usr/lib/postgresql/9.3 should have gone.
If you want to see the configuration of 9.1 then try running:
/usr/lib/postgresql/9.1/bin/pg_config.
The wrapper scripts which starts the server will use the file structure of /etc/postgresql and use the apropriate version. So /etc/postgresql/9.1/main will startup version as 9.1.
I want to restore a database in PostgreSQL but it can't. I have replaced pg_restore in bin folder but it's still not working. The message is :
pg_restore: [archiver] unsupported version (1.12) in file header
I solved this by upgrading postgresql from 8.X to 9.2.4. If you're using brew on Mac OS-X, use -
brew upgrade postgresql
Once this is done, just make sure your new postgres installation is at the top of your path. It'll look something like (depending on the version installation path) -
export PATH=/usr/local/Cellar/postgresql/9.2.4/bin:$PATH
This occurs when the archive was created with a version newer than the pg_restore you are using can support. The best way to fix this is to install a newer version of pg_restore. Note that this limitation has more recently gone away. I can use pg_restore from 9.1 against a 9.2 custom dump file for example.