From 3d30b6ca35a4e3899f3ad0c8f448441c0dfd8cba Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Thu, 3 Dec 2015 15:50:08 -0600 Subject: [PATCH 1/2] remove = after -o in mongodump command The -o= seems to work fine in 3.x but in 2.x it actually includes the equals sign in the path, resulting in "/=/tmp/tmp.XXXXXX". The mongodump command docs for neither 2.x nor 3.x list the equals sign as part of the -o or --out parameter. It seems to work fine in 3.x with or without the equals sign. Updated test to reflect change to -o --- commands | 2 +- tests/service_export.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands b/commands index b8aaf65..665f872 100755 --- a/commands +++ b/commands @@ -117,7 +117,7 @@ case "$1" in PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" [[ -n $SSH_TTY ]] && stty -opost - docker exec "$SERVICE_NAME" bash -c "DIR=\$(mktemp -d) && mongodump -d $SERVICE -o=\"\$DIR\" -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$SERVICE\" && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\"" + docker exec "$SERVICE_NAME" bash -c "DIR=\$(mktemp -d) && mongodump -d $SERVICE -o \"\$DIR\" -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$SERVICE\" && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\"" [[ -n $SSH_TTY ]] && stty opost ;; diff --git a/tests/service_export.bats b/tests/service_export.bats index afa4ae7..37f0f2d 100755 --- a/tests/service_export.bats +++ b/tests/service_export.bats @@ -25,6 +25,6 @@ teardown() { export ECHO_DOCKER_COMMAND="true" run dokku "$PLUGIN_COMMAND_PREFIX:export" l password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" - assert_output "docker exec dokku.mongo.l bash -c DIR=\$(mktemp -d) && mongodump -d l -o=\"\$DIR\" -u \"l\" -p \"$password\" --authenticationDatabase \"l\" && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\"" + assert_output "docker exec dokku.mongo.l bash -c DIR=\$(mktemp -d) && mongodump -d l -o \"\$DIR\" -u \"l\" -p \"$password\" --authenticationDatabase \"l\" && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\"" } From 179b4984a34361e16e322e60dc19f09d56548efa Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Thu, 3 Dec 2015 15:53:09 -0600 Subject: [PATCH 2/2] Redirect mongodump stdout to stderr In version 3.x, the output of mongodump is on stderr, but on 2.6.x it writes information to stdout. This change doesn't break 3.x in my tests but prevents extraneous junk in beginning of the tar file when exporting in 2.6.x. Updated test to match redirect in exec command. --- commands | 2 +- tests/service_export.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands b/commands index 665f872..6617707 100755 --- a/commands +++ b/commands @@ -117,7 +117,7 @@ case "$1" in PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" [[ -n $SSH_TTY ]] && stty -opost - docker exec "$SERVICE_NAME" bash -c "DIR=\$(mktemp -d) && mongodump -d $SERVICE -o \"\$DIR\" -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$SERVICE\" && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\"" + docker exec "$SERVICE_NAME" bash -c "DIR=\$(mktemp -d) && mongodump -d $SERVICE -o \"\$DIR\" -u \"$SERVICE\" -p \"$PASSWORD\" --authenticationDatabase \"$SERVICE\" 1>&2 && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\"" [[ -n $SSH_TTY ]] && stty opost ;; diff --git a/tests/service_export.bats b/tests/service_export.bats index 37f0f2d..38a9746 100755 --- a/tests/service_export.bats +++ b/tests/service_export.bats @@ -25,6 +25,6 @@ teardown() { export ECHO_DOCKER_COMMAND="true" run dokku "$PLUGIN_COMMAND_PREFIX:export" l password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" - assert_output "docker exec dokku.mongo.l bash -c DIR=\$(mktemp -d) && mongodump -d l -o \"\$DIR\" -u \"l\" -p \"$password\" --authenticationDatabase \"l\" && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\"" + assert_output "docker exec dokku.mongo.l bash -c DIR=\$(mktemp -d) && mongodump -d l -o \"\$DIR\" -u \"l\" -p \"$password\" --authenticationDatabase \"l\" 1>&2 && tar cf - -C \"\$DIR\" . && rm -rf \"\$DIR\"" }