-   Linux - Newbie (
-   -   postgres and setting the environment for PGDATA (

squadja 07-31-2003 02:07 PM

postgres and setting the environment for PGDATA
Now that I have figured out how to send an attachment with crontab, I am attempting to add the backup procedure to the cronjob.

su postgres
pg_dumpall > test

and the error I keep getting is:
postgres does not know where to find the database system data. You must specify the directory that contains the database system either by specifying the -D invocation option or by setting the PGDATA environment variable.



jdruin 08-13-2003 03:28 PM

You could run the command as:

pg_dumpall -D /var/lib/pgsql/data > test

where /var/lib/pgsql/data is the path to your postgres data directory. THIS VARIES BY VERSION. you may find data located in /usr/local/pgsql/data or somewhere else. Do a

find / -name data

and see if one of these two places shows up.

You can then set the PGDATA variable in your /etc/profile so that when a user logs in, the path will be permanently set. Also I recommend setting up variables for log, port, etc so you can refer to these in other operations such as using pg_ctl. For example, in my /etc/profile I added these lines:


Note that these are specific to my installation. You can do a

find / -name pgsql

to see where the log is located. Note that you will get back lots of folders named pgsql. You are looking for the one that is a log file so you have to use your head. Doing a

ls -l

on the results can tell you which are files and which are folders. Then you can check the ones that are files to see which one is the log. Of course if you find a file in you /var/log named pgsql, your probably safe with that one [lol].

Once you get the variables set up in your /etc/profile, exit and log back in for them to tale effect. Test by doing a


and see if you end up in your postgress data directory

All times are GMT -5. The time now is 02:13 AM.