Files
mongodb_backup/mongodb_backup.sh
2023-01-02 11:16:19 +01:00

21 lines
430 B
Bash
Executable File

#!/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