Merge pull request #40 from mcolyer/allow-postgres-restore
Allow use of postgres images with wal-e
This commit is contained in:
@@ -24,7 +24,7 @@ dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
|
|||||||
```
|
```
|
||||||
postgres:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name>
|
postgres:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name>
|
||||||
postgres:connect <name> Connect via psql to a postgres service
|
postgres:connect <name> Connect via psql to a postgres service
|
||||||
postgres:create <name> Create a postgres service
|
postgres:create <name> Create a postgres service with environment variables
|
||||||
postgres:destroy <name> Delete the service and stop its container if there are no links left
|
postgres:destroy <name> Delete the service and stop its container if there are no links left
|
||||||
postgres:export <name> > <file> Export a dump of the postgres service database
|
postgres:export <name> > <file> Export a dump of the postgres service database
|
||||||
postgres:expose <name> [port] Expose a postgres service on custom port if provided (random port otherwise)
|
postgres:expose <name> [port] Expose a postgres service on custom port if provided (random port otherwise)
|
||||||
@@ -52,6 +52,7 @@ dokku postgres:create lolipop
|
|||||||
# official postgres image
|
# official postgres image
|
||||||
export POSTGRES_IMAGE="postgres"
|
export POSTGRES_IMAGE="postgres"
|
||||||
export POSTGRES_IMAGE_VERSION="9.4.4"
|
export POSTGRES_IMAGE_VERSION="9.4.4"
|
||||||
|
export POSTGRES_CUSTOM_ENV="USER=alpha;HOST=beta"
|
||||||
dokku postgres:create lolipop
|
dokku postgres:create lolipop
|
||||||
|
|
||||||
# get connection information as follows
|
# get connection information as follows
|
||||||
|
|||||||
9
commands
9
commands
@@ -31,8 +31,13 @@ case "$1" in
|
|||||||
touch "$LINKS_FILE"
|
touch "$LINKS_FILE"
|
||||||
|
|
||||||
dokku_log_info1 "Starting container"
|
dokku_log_info1 "Starting container"
|
||||||
|
if [[ -n $POSTGRES_CUSTOM_ENV ]]; then
|
||||||
|
echo "$POSTGRES_CUSTOM_ENV" | tr ';' "\n" > "$SERVICE_ROOT/ENVIRONMENT"
|
||||||
|
else
|
||||||
|
echo "" > "$SERVICE_ROOT/ENVIRONMENT"
|
||||||
|
fi
|
||||||
SERVICE_NAME=$(get_service_name "$SERVICE")
|
SERVICE_NAME=$(get_service_name "$SERVICE")
|
||||||
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/var/lib/postgresql/data" -e "POSTGRES_PASSWORD=$password" -d --restart always --label dokku=service --label dokku.service=postgres "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
|
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/var/lib/postgresql/data" --env-file="$SERVICE_ROOT/ENVIRONMENT" -e "POSTGRES_PASSWORD=$password" -d --restart always --label dokku=service --label dokku.service=postgres "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
|
||||||
echo "$ID" > "$SERVICE_ROOT/ID"
|
echo "$ID" > "$SERVICE_ROOT/ID"
|
||||||
|
|
||||||
dokku_log_verbose_quiet "Waiting for container to be ready"
|
dokku_log_verbose_quiet "Waiting for container to be ready"
|
||||||
@@ -40,7 +45,7 @@ case "$1" in
|
|||||||
|
|
||||||
dokku_log_verbose_quiet "Creating container database"
|
dokku_log_verbose_quiet "Creating container database"
|
||||||
DATABASE_NAME="$(get_database_name "$SERVICE")"
|
DATABASE_NAME="$(get_database_name "$SERVICE")"
|
||||||
docker exec "$SERVICE_NAME" su - postgres -c "createdb -E utf8 $DATABASE_NAME"
|
docker exec "$SERVICE_NAME" su - postgres -c "createdb -E utf8 $DATABASE_NAME" 2> /dev/null || echo 'Already exists'
|
||||||
|
|
||||||
dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE"
|
dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE"
|
||||||
dokku "$PLUGIN_COMMAND_PREFIX:info" "$SERVICE"
|
dokku "$PLUGIN_COMMAND_PREFIX:info" "$SERVICE"
|
||||||
|
|||||||
Reference in New Issue
Block a user