#!/bin/bash #backup MongoDB OUT_DIR=`pwd`/backup DUMP=/usr/bin/mongodump DATE=`date +%Y_%m_%d` DB_USER=backup DB_PASS=74be16979710d4c4e7c6647856088456 rm -rf $OUT_DIR/* mkdir -p $OUT_DIR/$DATE $DUMP -h 172.16.69.131:27228 -u $DB_USER -p $DB_PASS --authenticationDatabase admin --authenticationMechanism=SCRAM-SHA-1 -d washpay --excludeCollection=service_progress --excludeCollection=DevicePortReport --excludeCollection=dev_status_record --excludeCollection=SIMCard --excludeCollection=device_control_info --excludeCollection=dealer_message --excludeCollection=complaint --excludeCollection=check_devices --excludeCollection=exception_log --excludeCollection=events --excludeCollection=on_sale_record --excludeCollection=operator_logs --excludeCollection=promotion_records --excludeCollection=temp_values --excludeCollection=test_record --excludeCollection=tester_log --excludeCollection=device_replacements --excludeCollection=ad_pv --excludeCollection=device_upload_info --excludeCollection=device_migration_histories --excludeCollection=device_port_last_report --excludeCollection=ConsumeRecord --excludeCollection=RechargeRecord --excludeCollection=MyUser --excludeCollection=unique_user --gzip --numParallelCollections=1 -o $OUT_DIR/$DATE tar -zcvf $OUT_DIR/washpay_small_$DATE.tar.gz $OUT_DIR/$DATE /opt/ossutil64 cp -f $OUT_DIR/washpay_small_$DATE.tar.gz oss://mongo-history/mongobackup/ rm -rf $OUT_DIR/* mkdir -p $OUT_DIR/$DATE $DUMP -h 172.16.69.131:27228 -u $DB_USER -p $DB_PASS --authenticationDatabase admin --authenticationMechanism=SCRAM-SHA-1 -d washpay -c MyUser --gzip -o $OUT_DIR/$DATE tar -zcvf $OUT_DIR/washpay_MyUser_$DATE.tar.gz $OUT_DIR/$DATE /opt/ossutil64 cp -f $OUT_DIR/washpay_MyUser_$DATE.tar.gz oss://mongo-history/mongobackup/ rm -rf $OUT_DIR/* mkdir -p $OUT_DIR/$DATE $DUMP -h 172.16.69.131:27228 -u $DB_USER -p $DB_PASS --authenticationDatabase admin --authenticationMechanism=SCRAM-SHA-1 -d washpay -c unique_user --gzip -o $OUT_DIR/$DATE tar -zcvf $OUT_DIR/washpay_unique_user_$DATE.tar.gz $OUT_DIR/$DATE /opt/ossutil64 cp -f $OUT_DIR/washpay_unique_user_$DATE.tar.gz oss://mongo-history/mongobackup/ year=`date '+%Y'` month=`date '+%m'` month=$(echo -e $month | sed -r 's/0*([0-9])/\1/') bash ./dumpdata.sh -y $year -m $month bash ./maketar.sh -y $year -m $month