Thread: Script Location
When I dump a database (creating a script from the pg_dump command), I can't just put it in any old directory and point psql at it. I have to put it in the /var/lib/pgsql subdirs before postgresql will accept it. Is this right? Am I doing something wrong? Is this a bug^H^H^Hfeature? Paul M. Foster
On Thu, Nov 16, 2000 at 12:22:34AM -0500, some SMTP stream spewed forth: > When I dump a database (creating a script from the pg_dump command), I > can't just put it in any old directory and point psql at it. I have to > put it in the /var/lib/pgsql subdirs before postgresql will accept it. > Is this right? Am I doing something wrong? Is this a bug^H^H^Hfeature? > > Paul M. Foster > http://www.postgresql.org/docs/user/app-pgdump.htm Description: ...pg_dump will produce the queries necessary to re-generate all user-defined types, functions, tables, indices, aggregates, and operators... Note the limitations (if you have not already done so). http://www.postgresql.org/docs/admin/backup.htm#AEN2278 Restoring The text files created by pg_dump are intended to be read in by the psql program. The general command form to restore a dump is psql dbname < infile where infile is what you used as outfile for the pg_dump command. The database dbname will not be created by this command, you must do that yourself before executing psql (e.g., with createdb dbname). psql supports similar options to pg_dump for controlling the database server location and the user names. See its reference page for more information. To answer your question: You seem to misunderstand pg_dump (?). To restore from a dump, just reate the database and psql [options] < dumpfile The dumpfile can be anywhere (accessible to your user). It actually does *not* belong under the pgsql directory. That sounds correct.. G'luck and cheers gh
Paul M Foster wrote: > > When I dump a database (creating a script from the pg_dump command), I > can't just put it in any old directory and point psql at it. I have to > put it in the /var/lib/pgsql subdirs before postgresql will accept it. > Is this right? Am I doing something wrong? Is this a bug^H^H^Hfeature? You just have to point the output of pg_dump to any directory owned by the user running pg_dump. Since you mention /var/lib/pgsql, I'm assuming you are using an RPM installation. If my assumption is incorrect, correct me, please. In the default RPM installation, /var/lib/pgsql serves multiple roles: /var/lib/pgsql is ~postgres /var/lib/pgsql/data is PGDATA /var/lib/pgsql/backups is designed as a repository for your dumps. This gives you a 'safe haven' for your dumps that is owned by the user postgres, which is the default database administration user for the RPM installation. If you attempt to pg_dump to a file in a directory not owned by postgres, you will get an error. Likewise, if you have a dumpfile from another system in a directory where the user postgres (or whatever user you are trying to pipe the dump through psql back in) doesn't have read and execute permissions, you will get an error. To correct this problem, set your permissions appropriately in the directory you wish to use. Hope that helps! -- Lamar Owen WGCR Internet Radio 1 Peter 4:11