automation script for postgresql

Could you please help how can I run automation script for postgresql after installing postgresql on Ubuntu? I need to automatize DB preparation before using it (create table, insert data, alter permissions).

I need to do it with the current rights of the user.
E.g., I have the only user admin_ubuntu. He has all rights to run psql.
All scripts are written but how can I run the script? usually, I need to edit configs ( I believe, /etc/postgresql/9.1/main/pg_hba.conf). But I do not want to do it.

  • How can I create and use a variable inside docker?
  • Select Node variables LISTEN and SERVER through a docker image
  • Get docker swarm manager node from jenkins job
  • Can I run DCE (Docker Container Executor) on Yarn with Kerberos?
  • Jenkins Docker Push to google cloud fails with an exception
  • Files generated through docker-compose run web rails g controller do not have permissions to edit
  • So, what I need is just to run sql which will make a lot of things. How can I do it to run it? The problem is that I need to do a lot of things to allow to run sql when the OS is immaculate (empty).

    It will be made every time when the Ubuntu will have been installed.

  • Docker RUN fails with “returned a non-zero code: 6”
  • Kubernetes behind explicit proxy
  • Multicast with Docker Swarm and overlay network
  • docker works only in the Quickstart Docker Terminal
  • Docker db container running. Another process with pid <id> is using unix socket file
  • Docker and Magento permission issues
  • One Solution collect form web for “automation script for postgresql”

    you should be able to run shell provisioning – following is example of what you can do:

    # creating user
    sudo -u postgres psql -c "CREATE USER admin WITH PASSWORD 'password';"
    # creating new db if needed .. might need 2 (dev/test)
    createdb -U vagrant mydevdb
    # if you have more complex things you'll need to put that in a create_db.sql file and run the script as
    sudo -u postgres psql < create_db.sql

    The create_db.sql file can contain any CREATE TABLE statement

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.