Created
September 1, 2022 09:11
-
-
Save aldobongio/db74f907383c911d8db97df9c5eb316c to your computer and use it in GitHub Desktop.
MongoDB 4.0 -> 4.2 -> 4.4 and back to 4.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pre_clean() { | |
printf "\n##### RESETTING DOCKER VOLUME AND CONTAINER... #####\n" | |
docker stop mongotest | |
docker rm -v mongotest | |
sudo rm -rf /tmp/data | |
} | |
start_mongo() { | |
printf "\n##### STARTING MONGO $1... #####\n" | |
docker run --name mongotest -v /tmp/data:/data/db -d mongo:$1 | |
sleep 5s | |
} | |
check_running() { | |
printf "\n##### CHECKING MONGO IS RUNNING... #####\n" | |
docker exec mongotest mongo --eval "db.stats().ok" | |
} | |
print_fcv() { | |
printf "\n##### PRINTING FCV... #####\n" | |
docker exec mongotest mongo --eval "db.adminCommand({getParameter:1,featureCompatibilityVersion:1})" | |
} | |
set_fcv() { | |
printf "\n##### SETTING FCV=$1 #####\n" | |
docker exec mongotest mongo --eval "db.adminCommand({setFeatureCompatibilityVersion: '$1'})" | |
} | |
clean_shutdown() { | |
printf "\n##### PERFORMING CLEAN SHUTDOWN... #####\n" | |
docker exec mongotest mongo --eval "db.adminCommand( { shutdown: 1 } )" | |
sleep 5s | |
docker rm -v mongotest # removes the stopped container, not the volume | |
} | |
print_logs() { | |
printf "\n##### PRINTING LOGS... #####\n" | |
docker logs mongotest | |
} | |
pre_clean | |
start_mongo '4.0.28' | |
check_running | |
print_fcv | |
clean_shutdown | |
start_mongo '4.2.21' | |
check_running | |
print_fcv | |
set_fcv '4.2' | |
print_fcv | |
clean_shutdown | |
start_mongo '4.4.15' | |
check_running | |
clean_shutdown | |
start_mongo '4.2.21' | |
check_running | |
set_fcv '4.0' | |
print_fcv | |
clean_shutdown | |
start_mongo '4.0.28' | |
check_running | |
print_logs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment