Pregunta

I have DB owned by postgres, and I need to dump it, but postgres user does not have rights to write. So it boils down to login to DB as postgres but under different user in OS. How can I do that? I tried -U postgres but get an error even without password prompt. Basically I seek for `mysql -u root -p' in Postgres.

¿Fue útil?

Solución

Dump to the standard output, and have another OS user write to the file.

Assuming you're root:

# (su postgres -c 'pg_dump -U postgres dbname') > /path/to/backup.sql

The resulting file will created and written by root.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top