mongodb backup - initial commit
This commit is contained in:
18
mongo_backup.sh
Executable file
18
mongo_backup.sh
Executable file
@@ -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
|
||||||
|
|
||||||
Reference in New Issue
Block a user