loadhistory.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. year=
  3. while getopts ":y:m:" opt; do
  4. case $opt in
  5. y)
  6. year=$OPTARG
  7. ;;
  8. m)
  9. month=$OPTARG
  10. ;;
  11. ?)
  12. echo "usage: dumpdata -y=2019 -m=2"
  13. exit 1
  14. ;;
  15. esac
  16. done
  17. if [ ! -n "$year" ]; then
  18. echo "no year paramerter"
  19. exit 1
  20. fi
  21. if [ ! -n "$month" ]; then
  22. output="dump/${year}"
  23. else
  24. start_month=$(printf "%02d" ${month})
  25. start_year=${year}
  26. next_month=$(expr ${month} + 1)
  27. if [ $next_month -gt 12 ]; then
  28. end_month="01"
  29. end_year=$(expr ${year} + 1)
  30. else
  31. end_month=$(printf "%02d" ${next_month})
  32. end_year=${year}
  33. fi
  34. echo "$(pwd)/dump/${start_year}_${start_month}_01-${end_year}_${end_month}_01"
  35. output="$(pwd)/dump/${start_year}_${start_month}_01-${end_year}_${end_month}_01"
  36. fi
  37. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d report_his -c dealer_income_proxies --gzip ${output}/report/dealer_income_proxies.bson.gz --noIndexRestore
  38. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d report_his -c dealer_daily_stats --gzip ${output}/report/dealer_daily_stats.bson.gz --noIndexRestore
  39. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d report_his -c device_daily_stats --gzip ${output}/report/device_daily_stats.bson.gz --noIndexRestore
  40. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d report_his -c group_daily_stats --gzip ${output}/report/group_daily_stats.bson.gz --noIndexRestore
  41. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d report_his -c DealerReport --gzip ${output}/report/DealerReport.bson.gz --noIndexRestore
  42. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d report_his -c DevReport --gzip ${output}/report/DevReport.bson.gz --noIndexRestore
  43. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d report_his -c GroupReport --gzip ${output}/report/GroupReport.bson.gz --noIndexRestore
  44. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d washpay_his -c ConsumeRecord --gzip ${output}/washpay/ConsumeRecord.bson.gz --noIndexRestore
  45. mongorestore -h 172.16.145.62:20000 --authenticationDatabase=admin -u guanli -p 67374030857714990597992655453345 -d washpay_his -c RechargeRecord --gzip ${output}/washpay/RechargeRecord.bson.gz --noIndexRestore