#!/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() { start if [ $? -eq 0 ] then echo “back successfully!” else echo “back failure!” fi }
directory is exist
if [ ! -d ${parentpath}/${nowtime} ]
then
mkdir pwd
/${nowtime}
fi
execute
echo “============= back end${nowtime}=============”