Last active
July 22, 2020 08:32
-
-
Save vbguard/a639147868954d2ddba10b0e4232d693 to your computer and use it in GitHub Desktop.
Backup mongo database with all collection to folder in shell
This file contains 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
# (1) prompt user, and read command line argument | |
read -p "Run the backUp DB script now? (y|n) : " answer | |
# (2) handle the command line argument we were given | |
while true | |
do | |
case $answer in | |
[yY]* ) read -p "Enter DB port: " port | |
read -p "Enter DB name: " dbName | |
read -p "Enter output file path with name or name: " output | |
mongodump --port $port -d $dbName -o $output | |
echo "Okay, well done." | |
break;; | |
[nN]* ) echo "Have, a nice day!" | |
exit;; | |
* ) echo "Dude, just enter Y or N, please."; break ;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment