error postgresql 9.4 when dumping data - postgresql-9.4

I have error like at the picture when I dump the data. I change ssl_renegotiation_limit=0 but I have same error. I have error
pg_dump: Dumping the contents of table "tunggakan" Failed: PQgetCopyData failed.
pg_dump: The command was : COPY public.tunggakan(blabla,blaaa,blabla) to stdout; "
I use the following syntax:
pg_dump --host localhost --port 5432 --username "postgres" --format custom --blobs --verbose --file "/root/thecontent.backup" "table name"

Related

How to restore psql DB using the different ownership

I am taking pg_dump with --no-owner permission and trying to restore it in another deb.
I took pg_dump using below command and restore it in another db using the psql command.
pg_dump dbname > dname.sql
psql -d dbname -f filename
When I try to access the db I got
"ERROR: must be owner of function *** (SQLSTATE 42501) " .
Then I noticed the DB table ownership is postgres instead of myuser. I tried to restore it using pg_restore as I used .sql format it is not allowing. Then I tried with psql -U myuser dbname -f filename. I got below error message, though the user id is available.
psql: error: FATAL: Peer authentication failed for user "****"
How do I correct it while taking the dump or while restoring how to include the user1 permission?

pg_restore: [archiver] input file does not appear to be a valid archive

i backup local database use
pg_dump -h localhost -p 5432 -U postgres -W -F t test_db > .\local-11-06.tar
then i drop test_db and recreate by
CREATE DATABASE test_db ENCODING 'UTF8'
then restore by pg_restore
pg_restore -h localhost -U postgres -p 5432 --dbname=test_db --verbose .\local-11-06.tar
but error with
pg_restore: [archiver] input file does not appear to be a valid archive
What might be wrong?
(my PC info : windows 10 with postgresql 11)
P.S.
it is work on CMD but failed on PowerShell.(Encoding? i'm in JP)

Postgres Restore single table from full .backup file

I try to restore only one table from the Postgres full backup file (.backup). Here is the command line:
/usr/lib/postgresql/9.4/bin/pg_restore --host 'localhost' --port 5432 --schema="schema1" --table="table1" --username "postgres" --dbname "DB4TEST" --no-password --verbose "/path/to/fullDB.backup"
But I get this error:
Segmentation fault(core dumped)
Can anyone tell me where I went wrong?

How to restore postgres db from gzip file using psql? (arelle: XBRL SEC DB)

I downloaded the xbrldb_SEC_pg_2014-11-02.pg.gzip postgres pg_dump file from arelle.org. I then ran the schema ddl file in pgAdminIII and it recreated all of the databases, functions, etc.
When I try to restore the databases using the following:
desktop:~/Downloads$ sudo postgres zcat xbrldb_SEC_pg_2014-11-02.pg.gzip | psql -U postgres public
I get:
sudo: postgres: command not found psql: FATAL: Peer authentication failed for user "postgres"
I can zcat the file into a file to expand it. Looks like it is a pg_dump file.
postgres=> pg_restore -a /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.txt
postgres-> ;
ERROR: syntax error at or near "pg_restore"
LINE 1: pg_restore -a /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-0...
^
postgres=> pg_restore -a postgres /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.txt;
ERROR: syntax error at or near "pg_restore"
LINE 1: pg_restore -a postgres /home/jeremy/Downloads/xbrldb_SEC_pg_...
So then I tried to use PG Admin III, and my output:
/usr/bin/pg_restore --host localhost --port 5432 --username "postgres" --dbname "public" --role "postgres" --no-password --section data --data-only --exit-on-error --table accession --schema public --verbose "/home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.backup"
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.
Process returned exit code 1.
May I please ask what I need to do to get the databases restored?
Does anyone know what I need to do to get the database updated from 2014-11-02 to the current date?
You should run psql as postgres user, not zcat, so try to use following:
zcat xbrldb_SEC_pg_2014-11-02.pg.gzip | sudo -u postgres psql public
PS pg_restore is an utility, not a PostgreSQL command, that means you should run it from command line, not from psql.

Postgres restore from .dump file: Invalid byte sequence for encoding "UTF8"

I've downloaded the latest copy of my heroku database with
$ curl -o latest.dump `heroku pg:backups public-url --app myapp`
And this gives a file with the following type on my local machine:
$ file db/latest.dump
db/latest.dump: PostgreSQL custom database dump - v1.12-0
I'm trying to import this into my local Postgres DB (my_db) using psql. However, I'm getting lots of errors:
$ psql my_db < db/latest.dump
...
psql:db/latest.dump:119425: invalid command \?A~??ܣb?{#?+????LS??
psql:db/latest.dump:119426: invalid command \D%!ѡ/F??g????A???dC????|2?M?$?8GTJ??c?E?;??֛Sh??S?[NP?f?2?+H?W????k
... [thousands of lines]
psql:db/latest.dump:261719: ERROR: invalid byte sequence for encoding "UTF8": 0xba
The command psql -f db/latest.dump my_db fails the same way.
What needs to be done in order to import this file locally into a new database with the same schema, etc?
I was able to use pg_restore to solve the problem:
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d my_db db/latest.dump