unify dump and restore scripts

This commit is contained in:
Davide Alberani 2017-11-28 22:24:38 +01:00
parent ade59480d9
commit 0824ffffab
3 changed files with 27 additions and 7 deletions

View file

@ -6,4 +6,4 @@ LABEL \
VOLUME ["/data"]
COPY run.sh /
CMD ["/run.sh"]
ENTRYPOINT ["/run.sh"]

View file

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

26
docker-tools/run.sh Executable file
View file

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