Skip to content
This repository has been archived by the owner on Jun 29, 2019. It is now read-only.

Commit

Permalink
postgres engine support
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydpick committed Feb 4, 2016
1 parent 9da5b64 commit 76eb551
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
26 changes: 24 additions & 2 deletions README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ Engines are used to load the backup that was retrieved by the transport into the

* MongoDB
* MySQL
* PostgreSQL

Custom engines can also be loaded at runtime if they are placed in `/etc/uphold/engines`

Expand Down Expand Up @@ -233,7 +234,7 @@ Unless you need to change any of the defaults, a standard configuration for Mong
settings:
database: your_db_name

###### Full MongoDB Engine Example
###### Full `mongodb` Engine Example

engine:
type: mongodb
Expand All @@ -251,7 +252,7 @@ Unless you need to change any of the defaults, a standard configuration for Mong
database: your_database_name
sql_file: your_sql_file.sql

###### Full mysql Engine Example
###### Full `mysql` Engine Example

engine:
type: mysql
Expand All @@ -262,6 +263,27 @@ Unless you need to change any of the defaults, a standard configuration for Mong
port: 3306
sql_file: MySQL.sql

##### PostgreSQL (type: `postgresql`)

engine:
type: mysql
settings:
database: your_database_name
sql_file: your_sql_file.sql

###### Full `postgresql` Engine Example

The `database` also becomes your username for when you run the tests.

engine:
type: postgresql
settings:
database: your_database_name
docker_image: postgres
docker_tag: 9.5.0
port: 5432
sql_file: PostgreSQL.sql

#### Tests

Tests are the final step in configuration. They are how you validate that the data contained within your backup is really what you want, and that your backup is operating correctly. Tests are written in Ruby using Minitest, this gives you the most flexibility in writing tests programmatically as it supports both Unit & Spec tests. To configure a test you simply provide an array of ruby files you want to run...
Expand Down
1 change: 0 additions & 1 deletion TODO.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
* Refactor the way that the UI collects up the logs, it's slow and cumbersome
* Create an upstart/systemd script to start the uphold-ui container with the correct volume mounts
* Some sort of authentication
* PostgreSQL support
* SQLite support
2 changes: 1 addition & 1 deletion dockerfiles/tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ruby:2.3-slim

RUN apt-get update
RUN apt-get -y install libmysqlclient-dev mysql-client libpq-dev libsqlite3-dev mongodb-clients
RUN apt-get -y install libmysqlclient-dev mysql-client libpq-dev libsqlite3-dev mongodb-clients postgresql-client

WORKDIR /opt/uphold
COPY Gemfile /opt/uphold/Gemfile
Expand Down
21 changes: 21 additions & 0 deletions lib/engines/postgresql.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Uphold
module Engines
class Postgresql < Engine

def initialize(params)
super(params)
@docker_image ||= 'postgres'
@docker_tag ||= '9.5.0'
@docker_env ||= ["POSTGRES_USER=#{@database}", "POSTGRES_DB=#{@database}"]
@port ||= 5432
@sql_file ||= 'PostgreSQL.sql'
end

def load_backup(path)
Dir.chdir(path) do
run_command("psql --no-password --set ON_ERROR_STOP=on --username=#{@database} --host=#{container_ip_address} --port=#{@port} --dbname=#{@database} < #{@sql_file}")
end
end
end
end
end

0 comments on commit 76eb551

Please sign in to comment.