A
A
Alexander N++2014-07-02 09:26:24
MongoDB
Alexander N++, 2014-07-02 09:26:24

Mongo backup of all databases, via bash script, where can I get it?

Maybe someone has a simple bash script lying around?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rpsl, 2014-07-02
@Rpsl

#!/bin/bash
mongodump -h 127.0.0.1

S
Slipeer, 2014-07-02
@Slipeer

Offhand there is a good script: https://gist.github.com/infynyxx/403885

E
enotter, 2014-11-18
@enotter

#!/bin/sh
DATE=`/bin/date "+%Y%m%d-%H.%M.%S"`
dest_dir="/var/lib/mongo_backup"
/bin/mkdir -p $dest_dir /mongo.$DATE
mongodump $dump_flags -o $dest_dir/mongo.$DATE
cd $dest_dir/mongo.$DATE && for i in `ls`; do tar czvf $i.tar.gz $i; done
cd $dest_dir/mongo.$DATE && for i in `ls -l | grep -E '^d'`; do rm -rf $i; done
echo "mongo.$DATE.tgz moved to backup-server."
find ${dect_dir} -type f -mtime +21 -exec rm {} \;
exit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question