12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #!/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
- 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_ts=`date -u -d ${start_day} +%s`000
- end_day="${end_year}-${end_month}-01"
- end_ts=`date -u -d ${end_day} +%s`000
- echo $start_day
- echo $start_ts
- echo $start_month
- echo $start_year
- echo $end_day
- echo $end_ts
- echo $end_month
- echo $end_year
- echo "`pwd`/backup/${start_year}_${start_month}_01-${end_year}_${end_month}_01"
-
- output="`pwd`/backup/${start_year}_${start_month}_01-${end_year}_${end_month}_01"
- rm -rf $output
- mkdir -p $output
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d report -c dealer_income_proxies -q='{"$and": [{"dateTimeAdded": {"$gte":{"$date": {"$numberLong": "'${start_ts}'"}}}}, {"dateTimeAdded": {"$lt": {"$date": {"$numberLong": "'${end_ts}'"}}}}]}' --gzip -o ${output}
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d report -c dealer_daily_stats -q='{"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}' --gzip -o ${output}
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d report -c device_daily_stats -q='{"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}' --gzip -o ${output}
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d report -c group_daily_stats -q='{"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}' --gzip -o ${output}
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d report -c DealerReport -q='{"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}' --gzip -o ${output}
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d report -c DevReport -q='{"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}' --gzip -o ${output}
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d report -c GroupReport -q='{"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}' --gzip -o ${output}
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d washpay -c RechargeRecord -q='{"$and": [{"dateTimeAdded": {"$gte":{"$date": {"$numberLong": "'${start_ts}'"}}}}, {"dateTimeAdded": {"$lt": {"$date": {"$numberLong": "'${end_ts}'"}}}}]}' --gzip -o ${output}
- mongodump --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 -d washpay -c ConsumeRecord -q='{"$and": [{"dateTimeAdded": {"$gte":{"$date": {"$numberLong": "'${start_ts}'"}}}}, {"dateTimeAdded": {"$lt": {"$date": {"$numberLong": "'${end_ts}'"}}}}]}' --gzip -o ${output}
|