Files
mongodb_backup/mongo_backup.sh

19 lines
321 B
Bash
Executable File

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