Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One of the coolest things you can do with Postgresql is pipe pg_dump straight into psql connected to another cluster on another host.


I recently set up some scripts to do this and it wasn't quite as simple as I had hoped. I had to pass some extra flags to pg_restore for --no-owner --no-acl, and then it still had issues when the target db has data in it, even with --clean and --create. And sometimes it would leave me in a state where it dropped the database and had trouble restoring, and so I'd be totally empty.

What I ended up doing is creating a new database, pg_restore'ing into that one with --no-owner and --no-acl, forcibly dropping the old database, and then renaming the new to the old one's name. This has the benefit of not leaving me high and dry should there be an issue with restoring.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: