• mongodb按月份拆库


    #!/bin/bash
    begintime=`date -d "-$1 month" +%Y-%m`
    lasttime=`date -d "-$2 month" +%Y-%m`
    mogotime=`date -d "-$1 month" +%Y%m`
    BeginTimestamp=$[$(date -d "$begintime-1 00:00:00" +%s%N)/1000000]
    LastTimestamp=$[$(date -d "$lasttime-1 00:00:00" +%s%N)/1000000]
    mkdir /data/monbak/${mogotime} -p
    bak_dir=/data/monbak/${mogotime}
    gte=$gte
    lt=$lt
    cr="create_time"
    create_time=''{$cr:{$gte:$BeginTimestamp,$lt:$LastTimestamp}}''
    del_sql="
    use accountdb;
    db.a_payment_info.remove($create_time)
    "
    export_mon() {
    cd ${bak_dir}
    /usr/local/mongodb/bin/mongoexport -d accountdb -c a_payment_info -q $create_time -o a_payment_info.json >./export.log 2>&1
    }
    import_mon() {
    cd ${bak_dir}
    /usr/local/mongodb/bin/mongoimport -d accountdb -c a_payment_info_$mogotime ./a_payment_info.json >./import.log 2>&1
    }
    del_mon() {
    cd ${bak_dir}
    echo "$del_sql"|/usr/local/mongodb/bin/mongo >./del.log 2>&1
    }

    proof() {
    if [ $check_export == $check_del ] && [ $check_export == $check_del ]
    then echo "TRUE"
    else echo "FALSE"
    fi
    }
    main() {
    export_mon
    import_mon
    del_mon
    }
    main

  • 相关阅读:
    Java三年经验
    系统集成项目管理 - 笔记
    ZK
    older versions of the JRE and JDK
    [提高组集训2021] 古老的序列问题
    CF1556G Gates to Another World
    Codeforces Round #743 (Div. 1)
    [提高组集训2021] 蚂蚁
    [LOJ 6669] Nauuo and Binary Tree
    [ABC219H] Candles
  • 原文地址:https://www.cnblogs.com/lishug/p/13219665.html
Copyright © 2020-2023  润新知