jeffutter / dokku-postgresql-plugin

Plugin to setup postgresql accounts for containers deployed with Dokku
GNU General Public License v2.0
35 stars 13 forks source link

How to import sql dump using this plugin? #16

Closed StarWar closed 9 years ago

StarWar commented 9 years ago

I'm using this plugin and I was able to install it. And now I want to import my existing database and I don't see any command here to import sql dump in this plugin.

thepuzzlemaster commented 9 years ago

We switched to using this plugin to get this functionality: https://github.com/Kloadut/dokku-pg-plugin

Which is strange because its syntax actually matches jeffutter's mongodb plugin syntax more closely than this one. We were using his mongodb plugin first, so we initially installed this one for postgres, but were surprised to find out that the other plugin matched the mongodb syntax more closely. It was the lack of importing that initially led us to look elsewhere.

jeffutter commented 9 years ago

Importing with this plugin is not much different than importing using postgresql natively. The trick is that when connecting to localhost postgresql will tend to try and connect over a unix socket rather than a tcp socket. To import you can do something like this (off the top of my head, might not be exact)

psql -f dump.sql -h localhost -p 5432 -U admin target_db

I personally don't have much use to bake importing into the script. If someone would like to contribute this functionality I would gladly accept it.

jeffutter commented 9 years ago

An easier solution would be to implement commands in this script to dump/restore databases. If anyone wants to work on this I would appreciate it.. There is an open pull request about to be merged on my mongodb plugin for this feature that someone could use for inspiration: https://github.com/jeffutter/dokku-mongodb-plugin/pull/67

audy commented 9 years ago

I implemented dump and dump_all. See #18

jeffutter commented 9 years ago

Fixed in #18

audy commented 9 years ago

:smile_cat: