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

Commit 76eb551

Browse files
committed
postgres engine support
1 parent 9da5b64 commit 76eb551

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

README.mdown

+24-2
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ Engines are used to load the backup that was retrieved by the transport into the
206206

207207
* MongoDB
208208
* MySQL
209+
* PostgreSQL
209210

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

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

236-
###### Full MongoDB Engine Example
237+
###### Full `mongodb` Engine Example
237238

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

254-
###### Full mysql Engine Example
255+
###### Full `mysql` Engine Example
255256

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

266+
##### PostgreSQL (type: `postgresql`)
267+
268+
engine:
269+
type: mysql
270+
settings:
271+
database: your_database_name
272+
sql_file: your_sql_file.sql
273+
274+
###### Full `postgresql` Engine Example
275+
276+
The `database` also becomes your username for when you run the tests.
277+
278+
engine:
279+
type: postgresql
280+
settings:
281+
database: your_database_name
282+
docker_image: postgres
283+
docker_tag: 9.5.0
284+
port: 5432
285+
sql_file: PostgreSQL.sql
286+
265287
#### Tests
266288

267289
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...

TODO.mdown

-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
* Refactor the way that the UI collects up the logs, it's slow and cumbersome
1313
* Create an upstart/systemd script to start the uphold-ui container with the correct volume mounts
1414
* Some sort of authentication
15-
* PostgreSQL support
1615
* SQLite support

dockerfiles/tester/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ruby:2.3-slim
22

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

66
WORKDIR /opt/uphold
77
COPY Gemfile /opt/uphold/Gemfile

lib/engines/postgresql.rb

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Uphold
2+
module Engines
3+
class Postgresql < Engine
4+
5+
def initialize(params)
6+
super(params)
7+
@docker_image ||= 'postgres'
8+
@docker_tag ||= '9.5.0'
9+
@docker_env ||= ["POSTGRES_USER=#{@database}", "POSTGRES_DB=#{@database}"]
10+
@port ||= 5432
11+
@sql_file ||= 'PostgreSQL.sql'
12+
end
13+
14+
def load_backup(path)
15+
Dir.chdir(path) do
16+
run_command("psql --no-password --set ON_ERROR_STOP=on --username=#{@database} --host=#{container_ip_address} --port=#{@port} --dbname=#{@database} < #{@sql_file}")
17+
end
18+
end
19+
end
20+
end
21+
end

0 commit comments

Comments
 (0)