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))