diff --git a/Dockerfile b/Dockerfile index 45a2b10..400e5ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ LABEL \ vendor="RaspiBO" EXPOSE 5242 +VOLUME ["/eventman/data"] RUN \ apt-get update && \ diff --git a/docker-tools/run.sh b/docker-tools/run.sh index b43b358..667efcb 100755 --- a/docker-tools/run.sh +++ b/docker-tools/run.sh @@ -8,19 +8,20 @@ cmd="$1" if [ "${cmd}" = "--dump" ] ; then echo "INFO: dumping..." - mongodump --host mongo --out /tmp/ --db eventman + mongodump --host mongo --out /tmp/ --db eventman || (echo "ERROR: unable to dump the database" ; exit 10) 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 + exit 20 fi echo "INFO: restoring $2..." - tar xfz "/data/$2" -C /tmp + tar xfz "/data/$2" -C /tmp || (echo "ERROR: error unpacking file" ; exit 21) + mongo --host mongo eventman --eval "db.dropDatabase()" || (echo "ERROR: error dropping the database" ; exit 22) mongorestore --host mongo -d eventman /tmp/eventman else echo "ERROR: command not recognized: use --dump or --restore dumps/file.tgz" - exit 3 + exit 30 fi