diff --git a/docker-tools/mongodump/Dockerfile b/docker-tools/Dockerfile similarity index 84% rename from docker-tools/mongodump/Dockerfile rename to docker-tools/Dockerfile index 4a582c0..b766332 100644 --- a/docker-tools/mongodump/Dockerfile +++ b/docker-tools/Dockerfile @@ -6,4 +6,4 @@ LABEL \ VOLUME ["/data"] COPY run.sh / -CMD ["/run.sh"] +ENTRYPOINT ["/run.sh"] diff --git a/docker-tools/mongodump/run.sh b/docker-tools/mongodump/run.sh deleted file mode 100755 index bb8df70..0000000 --- a/docker-tools/mongodump/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -mongodump --host mongo --out /tmp/ --db eventman -cd /tmp -tar cfz /data/eventman-dump-`date +'%Y-%m-%dT%H:%M:%S'`.tgz eventman - diff --git a/docker-tools/run.sh b/docker-tools/run.sh new file mode 100755 index 0000000..b43b358 --- /dev/null +++ b/docker-tools/run.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ $# -lt 1 ] ; then + exit 1 +fi + +cmd="$1" + +if [ "${cmd}" = "--dump" ] ; then + echo "INFO: dumping..." + mongodump --host mongo --out /tmp/ --db eventman + cd /tmp + tar cfz /data/eventman-dump-`date +'%Y-%m-%dT%H:%M:%S'`.tgz eventman +elif [ "${cmd}" = "--restore" ] ; then + if [ -z "$2" ] ; then + echo "ERROR: missing argument to --restore" + exit 2 + fi + echo "INFO: restoring $2..." + tar xfz "/data/$2" -C /tmp + mongorestore --host mongo -d eventman /tmp/eventman +else + echo "ERROR: command not recognized: use --dump or --restore dumps/file.tgz" + exit 3 +fi +