Обсуждение: pg_dumpall - Need advice
I need to write a database dump/backup shell script to cron but I can't seem to get pg_dumpall working. Could someone who has this working take a look at my configuration below and give me some pointers? It would appear that "/usr/lib/postgresql/bin/readpgenv: line 2: /etc/postgresql/postgresql.env: No such file or directory " would be a big tip off except I can't find that file on my system and have no idea what it is/does. I'm new to postgresql (obviously). Thanks for your time. -John
debian:~# dpkg -l | grep postgresql
ii postgresql 7.4.7-6sarge1 object-relational SQL database management sy
ii postgresql-cli 7.4.7-6sarge1 front-end programs for PostgreSQL
debian:~#
ii postgresql 7.4.7-6sarge1 object-relational SQL database management sy
ii postgresql-cli 7.4.7-6sarge1 front-end programs for PostgreSQL
debian:~#
debian:~# uname -a
Linux debian 2.4.27-2-386 #1 Mon May 16 16:47:51 JST 2005 i686 GNU/Linux
debian:~# su postgres
postgres@debian:/root$ cd
postgres@debian:~$ pwd
/var/lib/postgres
postgres@debian:~$ pg_dumpall > testdump
/usr/lib/postgresql/bin/readpgenv: line 2: /etc/postgresql/postgresql.env: No such file or directory
postgres@debian:~$
Linux debian 2.4.27-2-386 #1 Mon May 16 16:47:51 JST 2005 i686 GNU/Linux
debian:~# su postgres
postgres@debian:/root$ cd
postgres@debian:~$ pwd
/var/lib/postgres
postgres@debian:~$ pg_dumpall > testdump
/usr/lib/postgresql/bin/readpgenv: line 2: /etc/postgresql/postgresql.env: No such file or directory
postgres@debian:~$
Contents of /etc/postgresql:
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
# Database administrative login by UNIX sockets
local all postgres ident sameuser
#
# All other connections by UNIX sockets
local all all ident sameuser
#
# All IPv4 connections from localhost
host all all 127.0.0.1 255.255.255.255 ident sameuser
host all all 0.0.0.0 0.0.0.0 md5
#
# All IPv6 localhost connections
host all all ::1 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff ident sameuser
host all all ::ffff: 127.0.0.1/128 ident sameuser
#
# reject all other connection attempts
host all all 0.0.0.0 0.0.0.0 reject
# Database administrative login by UNIX sockets
local all postgres ident sameuser
#
# All other connections by UNIX sockets
local all all ident sameuser
#
# All IPv4 connections from localhost
host all all 127.0.0.1 255.255.255.255 ident sameuser
host all all 0.0.0.0 0.0.0.0 md5
#
# All IPv6 localhost connections
host all all ::1 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff ident sameuser
host all all ::ffff: 127.0.0.1/128 ident sameuser
#
# reject all other connection attempts
host all all 0.0.0.0 0.0.0.0 reject
J, Not using the debian packages myself, I'll take a guess that on line 2 of the file: /etc/postgresql/postgresql.env it is specifiying the /usr/lib/postgresql/bin/readpgenv for some function and you do not have the readpgenv script/binary on your system, so it exits. Perhaps that file comes with a package that did not get installed, though I would think debian's package manager would not allow that behavior. On Fri, 16 Sep 2005, J French wrote: > I need to write a database dump/backup shell script to cron but I can't seem > to get pg_dumpall working. Could someone who has this working take a look at > my configuration below and give me some pointers? It would appear that > "/usr/lib/postgresql/bin/readpgenv: line 2: /etc/postgresql/postgresql.env: > No such file or directory " would be a big tip off except I can't find that > file on my system and have no idea what it is/does. I'm new to postgresql > (obviously). Thanks for your time. -John -- Jeff Frost, Owner <jeff@frostconsultingllc.com> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954
Please, don't post in HTML. J French wrote: > I need to write a database dump/backup shell script to cron but I > can't seem to get pg_dumpall working. Could someone who has this > working take a look at my configuration below and give me some > pointers? It would appear that "/usr/lib/postgresql/bin/readpgenv: > line 2: /etc/postgresql/postgresql.env: No such file or directory " > would be a big tip off except I can't find that file on my system and > have no idea what it is/does. I'm new to postgresql (obviously). > Thanks for your time. -John Apparently a Debian-specific file, since I don't recognize it offhand and none of the RedHat(-derived) boxen I run have it. > debian:~# dpkg -l | grep postgresql > ii postgresql 7.4.7-6sarge1 object-relational SQL database > management sy > ii postgresql-cli 7.4.7-6sarge1 front-end programs for PostgreSQL > debian:~# Aside from my grumpiness about all things Debian... > debian:~# su postgres > postgres@debian:/root$ cd > postgres@debian:~$ pwd > /var/lib/postgres > postgres@debian:~$ pg_dumpall > testdump > /usr/lib/postgresql/bin/readpgenv: line 2: > /etc/postgresql/postgresql.env: No such file or directory > postgres@debian:~$ ... this works Just Fine for me on a fairly-bare Sarge box, with Postgres installed just to see what happens. Since you seem to be missing a semi-critical file (Debian-specific, unfortunately - and why it's in any way necessary is beyond me), try creating /etc/postgresql/postgresql.env with this content: (Watch for linewraps) ======BEGIN # postgresql debian package # # This section is supplied as part of the Debian package for PostgreSQL. # It sets the environment for an ordinary user of PostgreSQL and should # be executed by the .profile or equivalent for the postgres administrator # # It is automatically read by all six frontend programs (in the # postgresql-client package). [ -r /etc/postgresql/postmaster.conf ] && . /etc/postgresql/postmaster.conf PGDATA=${POSTGRES_DATA:-/var/lib/postgres/data} PGLIB=/usr/lib/postgresql/lib PGACCESS_HOME=/usr/lib/postgresql/share/pgaccess PGHOST= export PGLIB PGDATA PGACCESS_HOME PGHOST ======END If that doesn't help, try uninstalling the postgresql package, and reinstalling it. You may have to purge it and manually hunt down leftover files before reinstalling. > Contents of /etc/postgresql: Er, if this is truly PostgreSQL as installed from the standard Debian package, I sincerely hope that you meant /etc/postgresql/pg_hba.conf. FWIW, it looks identical to the fresh one I found just after installing. I see 5 files in /etc/postgresql: postgres@test2:/etc/postgresql$ ls -l total 32 -rw-r----- 1 root postgres 4885 2005-05-18 04:33 pg_hba.conf -rw-r----- 1 root postgres 1441 2005-05-18 04:33 pg_ident.conf -rw-r--r-- 1 root root 9058 2005-09-16 14:50 postgresql.conf -rw-r--r-- 1 root root 602 2005-05-18 04:33 postgresql.env -rw-r--r-- 1 root root 3458 2005-09-16 14:49 postmaster.conf -kgd (Debian just rubs me the wrong way. I always end up fighting some component instead of quickly and easily bending it to my usage.) -- Get your mouse off of there! You don't know where that email has been!