diff --git a/mongodb/mongodb-backup.sh b/mongodb/mongodb-backup.sh index 7e6ee9a..fcbd310 100644 --- a/mongodb/mongodb-backup.sh +++ b/mongodb/mongodb-backup.sh @@ -5,13 +5,16 @@ log() { } NOW=$(date '+%y-%m-%d-%H%M') -FILE=/etc/backup/${MONGODB_DB}-${NOW}.dump.gz +FILE="/etc/backup/${MONGODB_DB}-${NOW}.dump.gz" log "Create Backup $FILE" if [ -n "$MONGODB_USER" ] && [ -n "$MONGODB_PASSWORD" ]; then - URI="mongodb+srv://$MONGODB_USER:$MONGODB_PASSWORD@$MONGODB_HOST" + URI="mongodb://$MONGODB_USER:$MONGODB_PASSWORD@$MONGODB_HOST/$MONGODB_DB" else - URI="mongodb+srv://$MONGODB_HOST" + URI="mongodb://$MONGODB_HOST/$MONGODB_DB" fi -mongodump --archive=$FILE --gzip --db=$MONGODB_DB --uri="$URI" +# Remove the port number from MONGODB_HOST +MONGODB_HOST=$(echo "$MONGODB_HOST" | cut -d: -f1) + +mongodump --archive="$FILE" --gzip --uri="$URI"