Linux下MongoDB实现自动备份脚本
发布于 2年前 作者 feiquan 2151 次浏览

#!/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}=============”

回到顶部