Liunx Shell implements a backup of MongoDB
#!/bin/bash#program # this shell is used for backup of mongodb#history#2014/09/16 11:25 qiushipath=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/ Sbin:~/binexport pathtargetpath= '/home/muse68 ' nowtime=$ (date +%y%m%d%h%m) Start () {mongodump -d wedate -o ${targetpath}/${nowtime} }execute () {startif [ $? -eq 0 ]thenecho "back successfully" elseecho "back failure!" fi}if [ ! -d "${targetpath}/${nowtime}/" ]thenmkdir ${targetpath}/${ nowtime}fiexecuteecho "===========back end ${nowtime}==================="
Make backups every three minutes using the Linux crontab
# Create crontabcrontab-e# Edit crontab Content */3 * * * * sh above shell# restart Crond/etc/init.d/crond restartservice crond status# detailed content refer to Linux crontab
About MongoDB's scheduled backups under Linux