#!/bin/bash
数据库备份
nowtime=date +"%Y-%m-%d"
echo “============= back start ${nowtime}=============”
parentpath=/opt/mongodbback
cd ${parentpath}
start(){/usr/local/mongodb/bin/mongodump -h 127.0.0.1 -d DB -o ${parentpath}/${nowtime}}
execute(){startif [ $? -eq 0 ]thenecho “back successfully!”elseecho “back failure!”fi}
directory is exist
if [ ! -d ${parentpath}/${nowtime} ]thenmkdir
pwd/${nowtime}fi
execute
echo “============= back end${nowtime}=============”
本文介绍了一个bash脚本,用于自动化Mongodb数据库的备份过程,包括创建备份目录、执行备份操作以及检查备份是否成功。
283

被折叠的 条评论
为什么被折叠?



