Eu faço backup usando
pg_dump db_production > postgres_db.dump
e então copio para localhost usando scp.
Agora quando eu importo no meu banco de dados local dá um erro
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.
usando linha commad
pg_restore -d db_development postgres_db.dump
postgresql
backup
pg-restore
Haseeb Ahmad
fonte
fonte
The answer above didn't work for me, this worked:
psql db_development < postgres_db.dump
fonte
For me when i try to restore from remote host i used
worked fine. And if not remote just following command worked.
fonte
In order to create a backup using
pg_dump
that is compatible withpg_restore
you must use the--format=custom
/-Fc
when creating your dump.From the docs:
So your
pg_dump
command might look like:And your
pg_restore
command:fonte
For me, It's working like this one. C:\Program Files\PostgreSQL\12\bin> psql -U postgres -p 5432 -d dummy -f C:\Users\Downloads\d2cm_test.sql
fonte
if you use pg_dump with -Fp to backup in plain text format, use following command:
to copy all data to your database with name dbname
fonte
If you have a full DB dump:
If you have schemas kept separately, however, that won't work. Then you'll need to disable triggers for data insertion, akin to
pg_restore --disable-triggers
. You can then use this:cat database_data_only.gzip | gunzip | PGPASSWORD="your_pass" psql -h "your_host" -U root "your_database" -c 'SET session_replication_role = replica;' -f /dev/stdin
On a side note, it is a very unfortunate downside of postgres, I think. The default way of creating a dump in
pg_dump
is incompatible withpg_restore
. With some additional keys, however, it is. WTF?fonte