0

I have to import a xml file into a Postgres 9.4 database on SUSE SLES 12.

I have a scriptfile executed by a cronjob, but I have to move the xml file from a sourcedirectory to my postgres data directory (because postgres xml functions need to have the file there. Like described here: Import XML files to PostgreSQL).

My question: How can I move the file to this directory using a script file? Is there a way to do it without superuser rights?

1 Answers1

0

Check the postgres user's groups:

groups postgres

It may be "postgres".

I suppose you need to write in /var/lib/postgres (maybe in SUSE the folder is different), check the permission on the dir. If the group "postgres" has the ownership of the dir, add that group to the user that run the cronjob:

usermod -a -G postgres [user]

If the group isn't allowed to write the dir, add it:

chmod -R 775 postgres:postgres /var/lib/postgres

In this way, if you need to read/write into the postgres installation dir, you must only add an user to group postgres.

Daniele Licitra
  • 1,520
  • 21
  • 45