1
ElmerZhang 2012-09-19 11:15:07 +08:00 1
mongo [options] [db address] [file names (ending in .js)]
比如 mongo --host 127.0.0.1:27017 testdb remove.js remove.js内容: db.foo.remove({date:"2012-09-18"}) |
2
gavingeng OP |
3
ri0day 2012-09-19 14:04:58 +08:00
/data0/mongodb/bin/mongo 127.0.0.1:27015/admin /data0/mongodb/backup.js 1>>/data0/cron_backup.log 2>>&1
cat /data0/mongodb/backup.js base = "/data0/backup/" function showdate(n) { var uom = new Date(new Date()-0+n*86400000); uom = uom.getFullYear() + "-" + (uom.getMonth()+1) + "-" + uom.getDate(); return uom; } db.runCommand({fsync:1,lock:1}) runProgram("cp","-ar","/data0/mongodb/data",base+showdate(0)) db.$cmd.sys.unlock.findOne() removeFile(base+showdate(-8)) |