PostgreSQL's pg_restore error while restoring - postgresql

I took a backup of database from remote server using pg_dump from my local in directory format. The version of postgres remote server's is 9.3.23 and my postgres local version is 9.6. So, when i am trying to restore, the data gets restored but it's throwing few errors.
This is the command I used for dumping:
pg_dump -h 172.16.0.70 -U postgres -d enet -n finance -Fd -j5 -f fin
This is the command i used for restoring:
pg_restore -h 172.16.0.70 -U postgres -d newdb08aug19 -j5 fin
-- Dumped from database version 9.3.23
-- Dumped by pg_dump version 9.6.14
pg_restore: [archiver (db)] Error while INITIALIZING:
pg_restore: [archiver (db)] could not execute query: ERROR: unrecognized configuration parameter "idle_in_transaction_session_timeout"
Command was: SET idle_in_transaction_session_timeout = 0;
pg_restore: [archiver (db)] could not execute query: ERROR: unrecognized configuration parameter "row_security"
Command was: SET row_security = off;

Related

Unable to connect to Postgresl through PGBouncer

pgbouncer=# \q
postgres#dbvm2:~$ psql -p 6432 -U pcstssdbadmin postgres
psql: error: ERROR: query_timeout
postgres#dbvm2:~$ psql -p 5432 -U pcstssdbadmin postgres
psql: error: FATAL: Peer authentication failed for user "pcstssdbadmin"
postgres#dbvm2:~$ cd /etc/postgresql/12/main
postgres#dbvm2:/etc/postgresql/12/main$ ls -ltrh
total 92K

Postgres Pg_Dump failed due to non english character on database name

I have created a postgres data base by giving non ascii name example: "Química"
When I tried to take back up of the same database using following command I am getting the exception
pg_dump: [archiver (db)] connection to database "Química" failed: FATAL: database "Química" does not exist.
Command used:
--host 127.0.0.1 --port 7555 --username postgres --format=d --verbose --jobs=10 --compress 9 --file "C:\Delete\Archive" --dbname "Química" --schema "Archive_TVT"

Heroku restore from local database with pg:backups with "ERROR: must be owner of extension plpgsql"

The problem has already been approached here and here but without any outcome for me to work with.
I am backing up using as required in the Heroku documentation.
pg_dump -Fc --no-acl --no-owner --no-privileges -h [HOST] -U [DB_USER] [DB_NAME] > backup.dump
When I restore like so (the file's size is ~100MB):
heroku pg:backups --app [APP_NAME] restore 'https://[DUMP_URL]' [HEROKU_DATABASE_URL]
I receive an error message after the progress of uploading stops at 19.4MB and logs state:
$ heroku pg:backups --app [APP_NAME] info r081
=== Backup info: r081
Database: BACKUP
Started: 2016-04-29 10:10:37 +0000
Finished: 2016-04-29 10:11:31 +0000
Status: Failed
Type: Manual
Backup Size: 19.4MB
=== Backup Logs
2016-04-29 10:10:39 +0000: pg_restore: connecting to database for restore
2016-04-29 10:10:41 +0000: pg_restore: creating SCHEMA public
2016-04-29 10:10:41 +0000: pg_restore: creating EXTENSION plpgsql
2016-04-29 10:10:41 +0000: pg_restore: creating COMMENT EXTENSION plpgsql
2016-04-29 10:10:41 +0000: pg_restore: [archiver (db)] Error while PROCESSING TOC:
2016-04-29 10:10:41 +0000: pg_restore: [archiver (db)] Error from TOC entry 2474; 0 0 COMMENT EXTENSION plpgsql
2016-04-29 10:10:41 +0000: pg_restore: [archiver (db)] could not execute query: ERROR: must be owner of extension plpgsql
2016-04-29 10:10:41 +0000: Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
2016-04-29 10:10:41 +0000:
2016-04-29 10:10:41 +0000:
2016-04-29 10:10:41 +0000:
2016-04-29 10:10:41 +0000: pg_restore: creating SEQUENCE answer_seq
[...]
2016-04-29 10:10:48 +0000: pg_restore: executing SEQUENCE SET category_seq
2016-04-29 10:10:49 +0000: pg_restore: processing data for table "file"
2016-04-29 10:11:31 +0000: out of memory
2016-04-29 10:11:31 +0000: waiting for restore to complete
2016-04-29 10:11:31 +0000: restore done
2016-04-29 10:11:31 +0000: waiting for download to complete
2016-04-29 10:11:31 +0000: download done
I first thought it could be due to the table file which contains BLOBS. But I can't seem to understand why it should be a problem. The largest file is 4MB.
The logs also state that only 19.4 of the 100MB have been imported.
I use the following version of the heroku toolbelt:
heroku-toolbelt/3.43.0 (x86_64-linux-gnu) ruby/2.1.5
heroku-cli/4.30.0-2dfc0f4 (amd64-linux) go1.6.2
=== Installed Plugins
heroku-apps#2.0.3
heroku-cli-addons#0.3.0
heroku-fork#4.1.3
heroku-git#2.5.1
heroku-local#5.0.2
heroku-orgs#1.1.0
heroku-pg-extras
heroku-pipelines#1.1.5
heroku-run#3.2.3
heroku-spaces#2.1.2
heroku-status#2.1.4
I suppose my database plan was not big enough to support the operation. I can exclude the other issues statet in the heroku FAQ

postgresql: errors install and run postgresql-9.5

I installed two postgresql(s), 9.5 should use port 5433, 9.3.4 should use port 5432:
me#camb:/usr/lib/postgresql/9.5/bin$ ls -al psql
-rwxr-xr-x 1 root root 564464 Jan 7 14:54 psql
me#camb:/opt/pkgs/postgresql-9.3.4/bin$ ls -al psql
-rwxr-xr-x 1 root root 405960 Aug 5 18:52 psql
me#camb:/opt/pkgs/postgresql-9.3.4/bin$ cat /etc/group
postgres:x:200:
me#camb:/opt/pkgs/postgresql-9.3.4/bin$ groups postgres
postgres : postgres ssl-cert
I wrote a script to install postgresql-9.5 and migrate from 9.3.4 to 9.5
Problem 0: postgresql-9.5 can not start sucessfully and why status is online
Output during install:
* Starting PostgreSQL 9.5 database server
* The PostgreSQL server failed to start. Please check the log output:
2016-01-19 19:41:49 UTC [16523-1] LOG: database system was shut down at 2016-01-19 19:41:48 UTC
2016-01-19 19:41:49 UTC [16523-2] LOG: MultiXact member wraparound protections are now enabled
2016-01-19 19:41:49 UTC [16522-1] LOG: database system is ready to accept connections
2016-01-19 19:41:49 UTC [16527-1] LOG: autovacuum launcher started
2016-01-19 19:41:49 UTC [16529-1] [unknown]#[unknown] LOG: incomplete startup packet
...fail!
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing postgresql-9.5 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of postgresql:
postgresql depends on postgresql-9.5; however:
Package postgresql-9.5 is not configured yet.
dpkg: error processing postgresql (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin ...
No apport report written because the error message indicates its a followup error from a previous failure.
ldconfig deferred processing now taking place
Errors were encountered while processing:
postgresql-9.5
postgresql
E: Sub-process /usr/bin/dpkg returned an error code (1)
Error while installing Postgresql-9.5:1
Then I did some tests:
me#camb:/usr/lib/postgresql/9.5/bin$ sudo service postgresql start
* Starting PostgreSQL 9.5 database server [ OK ]
me#camb:/usr/lib/postgresql/9.5/bin$ sudo service postgresql status
9.5/main (port 5433): online
What do the above errors?
By the way, another error is:
ERROR: role "postgres" already exists
Problem 1: Why I cannot use /usr/lib/postgresql/9.5/bin/psql to loginto the database, but I can do this by /opt/pkgs/postgresql-9.3.4/bin/psql
me#camb:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5433 reporting_central postgres
psql (9.3.4, server 9.5.0)
WARNING: psql major version 9.3, server major version 9.5.
Some psql features might not work.
Type "help" for help.
reporting_central=# \q
me#camb:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5432 reporting_central postgres
psql (9.3.4)
Type "help" for help.
reporting_central=# \q
me#camb:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /usr/lib/postgresql/9.5/bin/psql -p 5433 reporting_central postgres
/usr/lib/postgresql/9.5/bin/psql: symbol lookup error: /usr/lib/postgresql/9.5/bin/psql: undefined symbol: PQsslInUse
me#camb:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /usr/lib/postgresql/9.5/bin/psql -p 5432 reporting_central postgres
/usr/lib/postgresql/9.5/bin/psql: symbol lookup error: /usr/lib/postgresql/9.5/bin/psql: undefined symbol: PQsslInUse
The error is "undefined symbol: PQsslInUse". what does this mean? Why I cannot use /usr/lib/postgresql/9.5/bin/psql to loginto the database, but I can do this by /opt/pkgs/postgresql-9.3.4/bin/psql?
Thanks
By the way, I run the following to do migration:
sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/pg_dumpall -p 5432 | sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5433
Thanks
You have to use the same libpq library as the one used in psql 9.5.
You should do the following:
export LD_LIBRARY_PATH=/usr/lib/postgresql/9.5/lib:$LD_LIBRARY_PATH
sudo /sbin/ldconfig /usr/lib/postgresql/9.5/lib
You mess up with different versions of postgresql.
To start/use 9.5, you must use the appropriate binaries: initdb, pg_ctl and psql (for example):
mkdir /usr/lib/postgresql/9.5/data
/usr/lib/postgresql/9.5/bin/initdb -D ../data/
/usr/lib/postgresql/9.5/bin/pg_ctl -D ../data/ -l logfile start
/usr/lib/postgresql/9.5/bin/psql -p 5432 -d template1
More info: https://www.postgresql.org/docs/devel/static/install-post.html
and PQsslInUse issue: http://postgresql.nabble.com/psql-error-on-postgresql-9-0-psql-symbol-lookup-error-psql-undefined-symbol-PQconnectdbParams-td5104930.html
The error is "undefined symbol: PQsslInUse"
I just ran into this problem myself. I discovered that the reason was because I compiled Postgres 9.5 from scratch into a particular directory and then decided that I wanted it elsewhere and moved the install to a new directory. Down the line when I went to restore my database with psql, I got the above error. I corrected the problem by deleting my installation directory, changing the PREFIX to the correct location, recompiling and reinstalling Postgres. psql worked fine after this.
I had the same problem
psql: symbol lookup error: psql: undefined symbol: PQsetErrorContextVisibility
And the solution is :
export LD_LIBRARY_PATH=$PGXZ_HOME/lib:${LD_LIBRARY_PATH}
I had a similar issue and finally found a solution:
My user did not have permission for the postgres installation.
What worked for me was to switch to the postgres user:
sudo su - postgres
psql
and then it worked no issues.

Making postgres backups from heroku database followers

Previously you used to be able to create database dumps of database followers on heroku.
heroku pgbackups:capture HEROKU_FOLLOWER_COLOR --expire
It has stopped working recently.
If I heroku logs --tail --ps pgbackups I get
2013-03-07T17:27:49+00:00 app[pgbackups]: dump_progress: start
2013-03-07T17:27:49+00:00 app[pgbackups]: pg_dump-9.2.1-64bit: [archiver (db)] query failed: ERROR: cannot use serializable mode in a hot standby
2013-03-07T17:27:49+00:00 app[pgbackups]: HINT: You can use REPEATABLE READ instead.
2013-03-07T17:27:49+00:00 app[pgbackups]: pg_dump-9.2.1-64bit: [archiver (db)] query was: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE
2013-03-07T17:27:49+00:00 app[pgbackups]: dump_progress: 0B
2013-03-07T17:27:49+00:00 app[pgbackups]:
2013-03-07T17:27:49+00:00 app[pgbackups]: dump_progress: error
Dumping from the main DATABASE_URL seems to work fine though.
Is this a recent change in heroku platform or am I doing anything wrong?
Also, is there a performance hit if I do a dump of the main database?
Backups from followers should be working again now. The failure was due to some changes we made to pgbackups (namely, adding the --serializable-deferrable flag for pg_dump). We missed that this wouldn't work on followers--sorry about that.
Thanks,
Maciek,
Heroku Postgres