[root@Mongodb01 ~]# cat mongosave.sh
host=`ifconfig eth1 | grep -w inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
PORTS=(27017 27018 27019)
bakdate=`date +"%Y%m%d"`
backpath=/home/backup/mongodb/$bakdate/
for port in ${PORTS[@]};do
mkdir -p $backpath$port
echo `mongodump -h $host -port $port -o $backpath$port`
sleep 60
cd $backpath
tar -zcvf $port.tar.gz $port
rm -Rf $port
done
find /home/backup/mongodb/ -mtime +7 -name "*.gz" -exec rm {} \;
多端口MONGODB备份脚本
最新推荐文章于 2024-09-02 20:14:39 发布