#!/bin/bash # script de sauvegarde mongodb rotate=15 rdir=${1:-/root/backups/mongodb} dir=${rdir}/$(date "+%Y.%m.%d") status_file=/var/run/zabbix/backup_mongodb.status error=0 mkdir -p $dir cd $dir mongodump --oplog --out mongodump 2> /dev/null error=$? if [ $error -eq 0 ] ; then find $rdir -maxdepth 1 -type d -mtime +${rotate} -exec rm -fr {} \; fi test -d ${status_file%/*} && echo $error > $status_file exit $error