Linux下MongoDB实现自动备份脚本
发布于 11 年前 作者 feiquan 11581 次浏览 最后一次编辑是 8 年前

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

2 回复

是的

回到顶部