mongo 备份
mongo backup
mongo 备份 秉承方便简单,易搭建原则,还是用docker来实现,镜像地址(https://hub.docker.com/r/carlding/mongobackup/) docker hub找到一个镜像,istepanov/mongodump可以实现本地monogo的备份,查阅其内部脚本,并没有开放传入远程数据库的接口,于是在此基础上改进 Dockerfile FROM istepanov/mongodump MAINTAINER qwding ADD backup.sh backup.sh ADD start.sh start.sh backup.sh #!/bin/bash set -e echo "Job started: $(date)" DATE=$(date +%Y%m%d_%H%M%S) FILE="/backup/backup-$DATE.tar.gz" echo "mongodump -h $MONGO_PORT_27017_TCP_ADDR -p $MONGO_PORT_27017_TCP_PORT -u $MONGO_USER -p $MONGO_PASSWORD -d $MONGO_DB" mongodump -h $MONGO_PORT_27017_TCP_ADDR -u $MONGO_USER -p $MONGO_PASSWORD -d $MONGO_DB tar -zcvf $FILE dump/ rm -rf dump/ echo "Job finished: $(date)" start.sh #!/bin/bash set -e CRON_SCHEDULE=${CRON_SCHEDULE:-0 1 * * *} if [[ "$1" == ‘no-cron’ ]]; then exec /backup.