Beispiel #1
0
def get_invoices_database():
    """ 每天6:40拉取药监单备份数据库"""
    db_name = 'invoices'
    filename = get_file_name(db_name)
    command = 'scp ssh wq:/data/daily_backup/{0} {1}'.format(
        filename, DATABASE_BACKUP_PATH)
    os.system(command)
Beispiel #2
0
def get_djangodrug_db():
    """ 周日 6:30 拉取基础数据库备份数据库"""

    db_name = 'djangodrug'
    filename = get_file_name(db_name)
    command = 'scp ssh wq:/data/daily_backup/{0} {1}'.format(
        filename, DATABASE_BACKUP_PATH)
    os.system(command)
Beispiel #3
0
def get_wq_database():
    """ 每天6:20拉取网签备份数据库"""

    db_name = 'wangqian_xs'
    filename = get_file_name(db_name)
    command = 'scp ssh wq:/data/daily_backup/{0} {1}'.format(
        filename, DATABASE_BACKUP_PATH)
    os.system(command)
Beispiel #4
0
def send_wq_database_test():
    """ 发送网签数据到测试服务器"""

    db_name = 'wangqian_xs'
    filename = get_file_name(db_name)
    command = 'scp /data/yumwei/daily_backup/{0} ssh new_wqtest:/data/yunwei/database_back'.format(
        filename)
    os.system(command)
    # 执行数据同步命令
    sync_database = '~/.pyenv/versions/yunwei/bin/fab -f /data/yumwei/celery_pro/fabfile.py sync_database'
    os.system(sync_database)
Beispiel #5
0
def sync_database():

    sql_path = '/data/yunwei/database_back/'
    db_name = 'wangqian_xs'
    filename = get_file_name(db_name)

    zip_file = '/data/yunwei/database_back/{0}'.format(filename)
    gunzip_cmd = 'cd {0} && gunzip {1}'.format(sql_path, zip_file)

    run(gunzip_cmd)

    sql_file = zip_file[:-3]

    sync = 'mysql -h 172.16.91.197 -uroot -P3308 -p{0} -f wqxs_fortest <  {1}'.format(
        NEW_TEST_PASS, sql_file)
    run(sync)

    rm_sql_file = 'rm {0}'.format(sql_file)
    run(rm_sql_file)