脚本启动后立即对mongodb数据库进行本地全量备份,获取oplog时间戳,然后每天定时进行增量备份,脚本已内置定时器,只需要把脚本加入开机启动。所有配置都在脚本内更改,脚本支持跨平台。
{\"ts\":{\"$gt\": {\"$timestamp\": {\"t\": 1582524149, \"i\": 1}}}}
使用python3.7.6和 mongo4.2.3
脚本依赖python schedule模块需要执行:
pip install schedule
或 pip3 install schedule
python3 mongodump_oplog.py
nohup python3 -u mongodump_oplog.py > out.log 2>&1 &
ps aux |grep python
kill -9 [进程id]
vim /etc/rc.d/rc.local
python3 /opt/mongodb/mongodump_oplog.py
chmod +x /opt/mongodb/mongodump_oplog.py
chmod +x /etc/rc.d/rc.local
原文地址:https://blog.csdn.net/u013210551/article/details/104513906