Win batch processing, timed to export MongoDB to JSON file

Source: Internet
Author: User
Tags goto

1. Call.bat

 to Use the This                                                                   TOOLS* * *1: Call Test.bat                                             [Yestoday'sdata]          ****rem * * * * * * * * * 2: Call Test.bat begin_date<yyyy-mm-dd> end_date<yyyy-mm-dd> [begin to end date's data] * * * * * Call Call_mongodb_export.bat Exit

2. Call_mongodb_export.bat

@ECHOOFFIF "%2 "= =" "GOTO sysdateREM****GETParamaterDATE****SETldate=%1SETrdate=%2SETtdate=%2SETfdate=%tdate:~0,4%%tdate:~5,2%%tdate:~8,2%gotoRUNREM****GETSysdate * * *: Sysdaterem****GETTODAY'S year,month,day ****set year=%date:~0,4%set month=%date:~5,2%set day=%date:~8,2%if%DATE:~5,1%==0 SET MONTH=%D Ate:~6,1%if%date:~8,1%==0 SET Day=%date:~9,1%rem * * * * GET yestoday'S Year,month,day * * * *SET/A day=%day%-1IF%day% EQU0 SET/A month=%month%-1IF%month% EQU0 (    SETMonth= A    SET/A year=%year%-1)IF%day% EQU0 (    IF%month% EQU1 SETday= to    IF%month% EQU3 SETday= to    IF%month% EQU5 SETday= to    IF%month% EQU7 SETday= to    IF%month% EQU8 SETday= to    IF%month% EQUTen SETday= to    IF%month% EQU A SETday= to    IF%month% EQU4 SETday= -    IF%month% EQU6 SETday= -    IF%month% EQU9 SETday= -    IF%month% EQU2 (        SETday= -        IF%year% EQU . SETday= in        IF%year% EQU2020 SETday= in        IF%year% EQU2024 SETday= in)) REM****FORMATDay,month * * *IF%day% LSSTen SETday=0%day%IF%month% LSSTen SETMonth=0%month%SETldate=%year%-%month%-%day%SETRdate=%ldate%SETFdate=%year%%month%%day%rem****EXPORTMONGODB * * * *:RUNSETexp=Pagermongodb_export.bat%ldate%%rdate%%fdate%%exp% PU001%exp% PU002

3. Mongodb_export.bat

@echo Offrem D:\mongodb\server\3.2\bin\mongoexport-h repset/172.*.*.96:27017,172.*.*. the:27017,172.*.*. 98:27017-U username-p passwd--authenticationdatabase=admin-d dbname-c colname-q"{funcno: ' PU001 ', ' Content.timestamp ': {$gte: ' 2016-08-02 ', $lt: ' 2016-08-03 '}} '-O D:\MongoDB_Export\PU001\PU001_ 20160803.jsonSet Mongoex=d:\mongodb\server\3.2\bin\mongoexport-h repset/172.*.*.:27017,172.*.*. the:27017,172.*.*. 98:27017-U username-p passwd--authenticationdatabase=admin-d dbname-c colname-q%mongoex%"{funcno: '%4 ', ' Content.timestamp ': {$gte: '%1 ', $lte: '%2 24:00:00 '}} '-O D:\MongoDB_Export\%4\%4_%3.json

Win batch processing, exporting MongoDB to JSON file regularly

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.