add shell command

This commit is contained in:
Davide Alberani 2017-11-29 08:59:58 +01:00
parent f53924396e
commit 94ab4ed788
3 changed files with 11 additions and 3 deletions

View file

@ -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
docker-tools/shell.sh Executable file
View file

@ -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

View file

@ -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