mongodb-backup 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # get wekan/mongo settings
  3. source $SNAP/bin/wekan-read-settings
  4. # make sure we have set minimum env variables for locale
  5. if [ -z "$LANG" ]; then
  6. export LANG=en_US.UTF-8
  7. fi
  8. export LC_ALL=C
  9. # If CPU does not support AVX, use Qemu that supports AVX.
  10. # Migratemongo is at https://github.com/wekan/migratemongo
  11. # and at directory /snap/${SNAP_NAME}/current/migratemongo/avx
  12. # is bash scripts like mongod, mongosh check avx support and use Qemu if needed.
  13. export PATH=/snap/${SNAP_NAME}/current/migratemongo/avx:/snap/${SNAP_NAME}/current/usr/bin:/snap/${SNAP_NAME}/current/bin:$PATH
  14. export LD_LIBRARY_PATH=/snap/${SNAP_NAME}/current/lib:/snap/${SNAP_NAME}/current/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
  15. if [ -z $1 ]; then
  16. DATE=`/bin/date +%Y%m%dT%H%M%S`
  17. mkdir -p $SNAP_COMMON/db-backups/
  18. ARCHIVE=$SNAP_COMMON/db-backups/wekan-$DATE.backup
  19. else
  20. ARCHIVE=$1
  21. fi
  22. # start mongodb backup
  23. [ "x" == "x${MONGODB_BIND_IP}" ] && MONGODB_BIND_IP="127.0.0.1"
  24. echo "using bind ip"
  25. mongodump --host $MONGODB_BIND_IP --port $MONGODB_PORT -d wekan --gzip --archive=${ARCHIVE}