123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #!/bin/bash
- year=
- while getopts ":y:m:" opt; do
- case $opt in
- y)
- year=$OPTARG
- ;;
- m)
- month=$OPTARG
- ;;
- ?)
- echo "usage: dumpdata -y=2019 -m=2"
- exit 1
- ;;
- esac
- done
- if [ ! -n "$year" ]; then
- echo "no year paramerter"
- exit 1
- fi
- if [ ! -n "$month" ]; then
- start_day="${year}-01-01"
- start_ts=$(date -u -d ${start_day} +%s)000
- start_month="${year}-01"
- next_year=$(expr ${year} + 1)
- end_day="${next_year}-01-01"
- end_ts=$(date -u -d ${end_day} +%s)000
- end_month="${next_year}-01"
- else
- start_month=$(printf "%02d" ${month})
- start_year=${year}
- next_month=$(expr ${month} + 1)
- if [ $next_month -gt 12 ]; then
- end_month="01"
- end_year=$(expr ${year} + 1)
- else
- end_month=$(printf "%02d" ${next_month})
- end_year=${year}
- fi
- start_day="${start_year}-${start_month}-01"
- start_time="${start_year}-${start_month}-01 00:00:00"
- start_ts=$(date -u -d ${start_day} +%s)000
- end_day="${end_year}-${end_month}-01"
- end_ts=$(date -u -d ${end_day} +%s)000
- end_time="${end_year}-${end_month}-01 00:00:00"
- fi
- echo "====================== device_daily_stats begin ============================="
- echo "use report;" >temp.js
- echo 'db.getCollection("device_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
- rm temp.js
- echo "use report_his;" >temp.js
- echo 'db.getCollection("device_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
- rm temp.js
- echo -e "====================== device_daily_stats end =============================\n"
- echo "====================== group_daily_stats begin ============================="
- echo "use report;" >temp.js
- echo 'db.getCollection("group_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
- rm temp.js
- echo "use report_his;" >temp.js
- echo 'db.getCollection("group_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
- rm temp.js
- echo -e "====================== group_daily_stats end =============================\n"
- echo "====================== dealer_daily_stats begin ============================="
- echo "use report;" >temp.js
- echo 'db.getCollection("dealer_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
- rm temp.js
- echo "use report_his;" >temp.js
- echo 'db.getCollection("dealer_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
- rm temp.js
- echo -e "====================== dealer_daily_stats end =============================\n"
- echo "====================== dealer_income_proxies begin ============================="
- echo "use report;" >temp.js
- echo 'db.getCollection("dealer_income_proxies").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
- rm temp.js
- echo "use report_his;" >temp.js
- echo 'db.getCollection("dealer_income_proxies").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
- rm temp.js
- echo -e "====================== dealer_income_proxies end =============================\n"
- echo "====================== ConsumeRecord begin ============================="
- echo "use washpay;" >temp.js
- echo 'db.getCollection("ConsumeRecord").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]},{"_id":1}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
- rm temp.js
- echo "use washpay_his;" >temp.js
- echo 'db.getCollection("ConsumeRecord").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]},{"_id":1}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
- rm temp.js
- echo -e "====================== ConsumeRecord end =============================\n"
- echo "====================== RechargeRecord begin ============================="
- echo "use washpay;" >temp.js
- echo 'db.getCollection("RechargeRecord").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]},{"_id":1}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
- rm temp.js
- echo "use washpay_his;" >temp.js
- echo 'db.getCollection("RechargeRecord").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]},{"_id":1}).count()' >>temp.js
- mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
- rm temp.js
- echo -e "====================== RechargeRecord end =============================\n"
|