commit 9befc0c034a78fc5d4a392738d364c9f54ef5f73 Author: Thomas Constans Date: Sun May 3 18:58:48 2020 +0200 mongodb backup - initial commit diff --git a/mongo_backup.sh b/mongo_backup.sh new file mode 100755 index 0000000..a8ec2dc --- /dev/null +++ b/mongo_backup.sh @@ -0,0 +1,18 @@ +#!/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 +