unify dump and restore scripts
This commit is contained in:
parent
ade59480d9
commit
0824ffffab
3 changed files with 27 additions and 7 deletions
|
@ -6,4 +6,4 @@ LABEL \
|
|||
VOLUME ["/data"]
|
||||
|
||||
COPY run.sh /
|
||||
CMD ["/run.sh"]
|
||||
ENTRYPOINT ["/run.sh"]
|
|
@ -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
26
docker-tools/run.sh
Executable 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
|
||||
|
Loading…
Reference in a new issue