The script is as follows
#vi /usr/sbin/bakmongo.sh
#!/bin/sh
# Name:bakmongo.sh
# This is a ShellScript For Auto DB Backup and Delete old Backup
#
backupdir=/data/dbbak
time=`date +% Y%m%d%H`
usr/local/mongodb/bin/mongodump -h 127.0.0.1 -d db1 -o $backupdir/db1_$time
tar -zcvf $backupdir/db1_$time.tar.gz $backupdir/db1_ $time
rm -rf $backupdir/db1_$time
find $backupdir -name "db1_*.tar.gz" -type f -mtime +5 -exec rm -rf {} \; > /dev/null 2>&1
run manually , there is no problem. The cron call found that
the
gz /local/mongodb/bin/mongodump -h 127.0.0.1 -d db1 -o $backupdir/db1_$time >/dev/null 2>&1
tar -zcvf $backupdir/db1_$time.tar.gz $backupdir/db1_$time >/dev/null 2>&1 to
get it done. It doesn’t work to
remove the tar v parameter
crontab executes the script tar package file is empty
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326266345&siteId=291194637
Ranking