I am authorized in a DB, I carry out:

pg_restore -v "/path/to/file.sql" 

And it outputs:

 pg_restore: [archiver] input file appears to be a text format dump. Please use psql. 

In a dump several DB are described.

What's the matter?

  • add the -v switch and see if there are any errors. - Mikhail Vaysman
  • @MikhailVaysman does not display this option. - Colibri
  • 3
    pg_restore - command line utility - nörbörnën
  • @norbornen I think where do you run it from? - Colibri
  • @Colibri by design it looks like from psql . - D-side

2 answers 2

You need to restore it like this

 psql < "/path/to/file.sql" 
  • In this file, CREATE DATABASE several databases is already described. - Colibri
  • how did you create "/path/to/file.sql" ? which team? - Mikhail Vaysman
  • @MikhailVaysman for sure, pg_dump - nörbörnĂ«n

@Colibri, catch three of my scripts (I use it under FreeBSD 9.0 for now), everything is working, everything works :)

db-backup.sh

 #!/bin/sh export IP=192.168.1.47 export DB=database_clients PGPASSWORD="password" /usr/local/bin/pg_dump -U pgsql -F t -f /root/temp/database_clients.tar database_clients xz -9 /root/temp/database_clients.tar 

db-restore.sh

 #!/bin/sh export IP=192.168.1.47 export DB=database_clients dropdb -p 5432 -h $IP -U pgsql -W $DB createdb -D pg_default -E UTF-8 -O pgsql -h $IP -U pgsql -W $DB echo "GRANT CONNECT, TEMPORARY ON DATABASE $DB TO public;" > $DB.grant.sql echo "GRANT ALL ON DATABASE $DB TO pgsql;" >> $DB.grant.sql psql -h $IP -U pgsql -W -f $DB.grant.sql $DB unxz database_clients.tar.xz pg_restore -h $IP -p 5432 -U pgsql -v --role="pgsql" -d $DB ~/temp/database_clients.tar 

db-reindex.sh

 #!/bin/sh export IP=192.168.1.47 export DB=database_clients PGPASSWORD="password" /usr/local/bin/reindexdb -U pgsql -h $IP --all 

When calling the script to restore - you will need to enter a password several times. My flaw, but everything has not been restored for a long time, only backed up. Oh, and laziness. I hope the scripts will serve as templates for your needs.

PS: With the paths between the scripts there are small "inconsistencies" - I needed it that way.