Browse Source

add shell command

Davide Alberani 6 years ago
parent
commit
94ab4ed788
3 changed files with 11 additions and 3 deletions
  1. 4 1
      docker-tools/run.sh
  2. 4 0
      docker-tools/shell.sh
  3. 3 2
      docs/DOCKER.md

+ 4 - 1
docker-tools/run.sh

@@ -6,7 +6,10 @@ fi
 
 cmd="$1"
 
-if [ "${cmd}" = "--dump" ] ; then
+if [ "${cmd}" = "--shell" ] ; then
+	echo "INFO: opening shell..."
+	mongo --host mongo eventman
+elif [ "${cmd}" = "--dump" ] ; then
 	echo "INFO: dumping..."
 	mongodump --host mongo --out /tmp/ --db eventman || (echo "ERROR: unable to dump the database" ; exit 10)
 	cd /tmp

+ 4 - 0
docker-tools/shell.sh

@@ -0,0 +1,4 @@
+#!/bin/sh
+
+docker build -t eventman-dump-and-restore .
+docker run -it --name eventman-shell --rm --network="eventman_default" -v `pwd`:/data --link=eventman_eventman-mongo_1:eventman-mongo eventman-dump-and-restore --shell

+ 3 - 2
docs/DOCKER.md

@@ -8,6 +8,7 @@ The data is stored in the *eventman_data* volume: do not cancel it.
 
 In the *docker-tools* directory there is a set of tools to build and run another container to dump and restore the database; you need the docker-compose running, to execute them. From that directory you can:
 
-* **dump.sh**: dump the current database in a file like *eventman-dump-2017-11-28T21:57:43.tgz*
-* **restore.sh** *eventman-dump-2017-11-28T21:57:43.tgz*: restore the given dump. Notice that the current database is completely removed, so DO NOT restore a dump if you don't have a backup of the current data
+- **dump.sh**: dump the current database in a file like *eventman-dump-2017-11-28T21:57:43.tgz*
+- **restore.sh**: *eventman-dump-2017-11-28T21:57:43.tgz*: restore the given dump. Notice that the current database is completely removed, so DO NOT restore a dump if you don't have a backup of the current data
+- **shell.sh**: open a shell for the database