sh zmongodb_dump.sh
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh zmongodb_dump.sh相关的知识,希望对你有一定的参考价值。
#!/bin/bash
HOST="[HOST]"
PORT="[PORT]"
DATABASE="[DATABASE]"
USERNAME="[USERNAME]"
PASSWORD="[PASSWORD]"
BACKUP_PATH="[FULL_PATH_TO_BACKUPS]"
HELP="
\n
\e[1mDump & Restore single MongoDB database\e[0m
\n\n
To create dump: \n
\e[1m./zmongodb_dump.sh dump\e[0m
\n\n
To restore dump (drops current collections): \n
\e[1m./zmongodb_dump.sh restore\e[0m
\n
"
mkdir -p $BACKUP_PATH
if [ "$1" = "restore" ]; then
DO_CMD="mongorestore --host $HOST --port $PORT --db $DATABASE --username $USERNAME --password $PASSWORD $BACKUP_PATH/$DATABASE --drop"
elif [ "$1" = "dump" ]; then
DO_CMD="mongodump --host $HOST --port $PORT --db $DATABASE --username $USERNAME --password $PASSWORD --out $BACKUP_PATH"
else
DO_CMD="echo -e $HELP"
fi
$DO_CMD
以上是关于sh zmongodb_dump.sh的主要内容,如果未能解决你的问题,请参考以下文章
如何使我的命令行在具有扩展名(.sh)和名称如“weird.sh.sh.sh”的文件上工作
sh sh_template.sh
sh sh.sh
Linux下面如何运行 SH文件
配置告警系统主脚本main.sh mon.sh load.sh 502.sh disk.sh
shell 脚本各种执行方式(source ./*.sh, . ./*.sh, ./*.sh)的区别