def transfer_origin_database_dump(): if mode.get_sync_mode() == mode.get_sync_modes().RECEIVER: get_origin_database_dump(helper.get_target_dump_dir()) system.check_target_configuration() elif mode.get_sync_mode() == mode.get_sync_modes().SENDER: system.check_target_configuration() put_origin_database_dump(helper.get_origin_dump_dir()) remove_origin_database_dump() elif mode.get_sync_mode() == mode.get_sync_modes().PROXY: helper.create_local_temporary_data_dir() get_origin_database_dump(system.default_local_sync_path) system.check_target_configuration() put_origin_database_dump(system.default_local_sync_path) elif system.option['is_same_client']: remove_origin_database_dump(True)
def check_configuration(): load_pip_modules() get_host_configuration() if not option['use_origin_ssh_key'] and mode.is_origin_remote(): option['ssh_password']['origin'] = get_password( mode.get_clients().ORIGIN) if mode.get_sync_mode() == mode.get_sync_modes().DUMP_REMOTE: option['ssh_password']['target'] = option['ssh_password']['origin'] if not option['use_target_ssh_key'] and mode.is_target_remote( ) and mode.get_sync_mode() != mode.get_sync_modes().DUMP_REMOTE: option['ssh_password']['target'] = get_password( mode.get_clients().TARGET) # first get data configuration for origin client parser.get_database_configuration(mode.get_clients().ORIGIN)
def extend_output_by_sync_mode(header): _sync_mode = mode.get_sync_mode() if (( _sync_mode == mode.get_sync_modes().RECEIVER or _sync_mode == mode.get_sync_modes().PROXY) and header == subject.ORIGIN) or ( ( _sync_mode == mode.get_sync_modes().SENDER or _sync_mode == mode.get_sync_modes().PROXY) and header == subject.TARGET) or (_sync_mode == mode.get_sync_modes().DUMP_REMOTE and (header == subject.ORIGIN or header == subject.TARGET)): return bcolors.BLACK + '[REMOTE]' + bcolors.ENDC if (_sync_mode == mode.get_sync_modes().SENDER and header == subject.ORIGIN) or (_sync_mode == mode.get_sync_modes().RECEIVER and header == subject.TARGET) or (_sync_mode == mode.get_sync_modes().DUMP_LOCAL and (header == subject.ORIGIN or header == subject.TARGET)): return bcolors.BLACK + '[LOCAL]' + bcolors.ENDC return ''
def upload_status(sent, size): sent_mb = round(float(sent) / 1024 / 1024, 1) size = round(float(size) / 1024 / 1024, 1) if (mode.get_sync_mode() == mode.get_sync_modes().PROXY): _subject = output.get_subject().LOCAL else: _subject = output.get_subject().ORIGIN + output.get_bcolors().BLACK + '[LOCAL]' + output.get_bcolors().ENDC sys.stdout.write( _subject + " Status: {0} MB of {1} MB uploaded". format(sent_mb, size, )) sys.stdout.write('\r')
def put_origin_database_dump(origin_path): sftp = ssh_client_target.open_sftp() if (mode.get_sync_mode() == mode.get_sync_modes().PROXY): _subject = output.get_subject().LOCAL else: _subject = output.get_subject().ORIGIN output.message( _subject, 'Uploading database dump', True ) # # ToDo: Download speed problems # https://github.com/paramiko/paramiko/issues/60 # sftp.put(origin_path + database.origin_database_dump_file_name + '.tar.gz', helper.get_target_dump_dir() + database.origin_database_dump_file_name + '.tar.gz', upload_status) sftp.close() print('')
def clean_up(): connect.remove_target_database_dump() if mode.get_sync_mode() == mode.get_sync_modes().PROXY: remove_temporary_data_dir()