Search code examples
linuxpostgresqlpg-restore

Unable to restore database backup on Postgresql-10.0


I am using postgresql-9.4 (port 5432) and postgresql-10.0 (port 5433) on my Linux machine (RHEL 7.4). Postgresql-9.4 was installed using yum repository and Postgresql-10.0 was installed using source in different partitions.

I have taken a backup of db (dtbase.backup) on Postgresql-9.4 using it's pg_dump and trying to restore this on Postgresql-10.0 using it's pg_restore.

While doing this, I am getting below error:

pg_restore: [archiver] unsupported version (1.13) in file header

I have checked different forums but unable to find the solution. Any help would be highly appreciated.


Solution

  • You'll have to upgrade your PostgreSQL v10 to 10.3 so that you have commit b8a2908f0ac735da68d49be2bce2d523e363f67b:

    Avoid using unsafe search_path settings during dump and restore.
    
    Historically, pg_dump has "set search_path = foo, pg_catalog" when
    dumping an object in schema "foo", and has also caused that setting
    to be used while restoring the object.  This is problematic because
    functions and operators in schema "foo" could capture references meant
    to refer to pg_catalog entries, both in the queries issued by pg_dump
    and those issued during the subsequent restore run.  That could
    result in dump/restore misbehavior, or in privilege escalation if a
    nefarious user installs trojan-horse functions or operators.
    
    This patch changes pg_dump so that it does not change the search_path
    dynamically.  The emitted restore script sets the search_path to what
    was used at dump time, and then leaves it alone thereafter.  Created
    objects are placed in the correct schema, regardless of the active
    search_path, by dint of schema-qualifying their names in the CREATE
    commands, as well as in subsequent ALTER and ALTER-like commands.
    
    Since this change requires a change in the behavior of pg_restore
    when processing an archive file made according to this new convention,
    bump the archive file version number; old versions of pg_restore will
    therefore refuse to process files made with new versions of pg_dump.
    
    Security: CVE-2018-1058
    

    Your 9.4 installation already uses archive format 1.13, which your v10 installation does not yet understand.

    Besides, you should always use pg_dump from the higher PostgreSQL version to upgrade a database.