def _restore_server(source_uuid, host, port, backup_image): """Restore the backup on the destination Server. :param source_uuid: The UUID of the source server. :param host: The hostname of the destination server. :param port: The port number of the destination server. :param backup_image: The backup image path. """ restore_user = _services_utils.read_config_value(_config.global_config, 'servers', 'restore_user') restore_passwd = _services_utils.read_config_value(_config.global_config, 'servers', 'restore_password') mysqlclient_binary = _services_utils.read_config_value( _config.global_config, 'sharding', 'mysqlclient_program') source_server = _server.MySQLServer.fetch(source_uuid) if not source_server: raise _errors.ServerError(SERVER_NOT_FOUND % source_uuid) #Build a backup image that will be used for restoring bk_img = _backup.BackupImage(backup_image) _backup.MySQLDump.restore_server(host, port, restore_user, restore_passwd, bk_img, mysqlclient_binary) _LOGGER.debug("Done with restore of server with host = %s, port = %s", host, port)
def _restore_shard_backup(shard_id, source_group_id, destn_group_id, backup_image, split_value, prune_limit, cmd): """Restore the backup on the destination Group. :param shard_id: The shard ID of the shard that needs to be moved. :param source_group_id: The group_id of the source shard. :param destn_group_id: The ID of the group to which the shard needs to be moved. :param backup_image: The destination file that contains the backup of the source shard. :param split_value: Indicates the value at which the range for the particular shard will be split. Will be set only for shard split operations. :param prune_limit: The number of DELETEs that should be done in one batch. :param cmd: Indicates the type of re-sharding operation """ restore_user = _services_utils.read_config_value( _config.global_config, 'servers', 'restore_user' ) restore_passwd = _services_utils.read_config_value( _config.global_config, 'servers', 'restore_password' ) mysqlclient_binary = _services_utils.read_config_value( _config.global_config, 'sharding', 'mysqlclient_program' ) destn_group = Group.fetch(destn_group_id) if destn_group is None: raise _errors.ShardingError(_services_sharding.SHARD_GROUP_NOT_FOUND % (destn_group_id, )) #Build a backup image that will be used for restoring bk_img = _backup.BackupImage(backup_image) for destn_group_server in destn_group.servers(): destn_group_server.connect() _backup.MySQLDump.restore_fabric_server( destn_group_server, restore_user, restore_passwd, bk_img, mysqlclient_binary ) #Setup sync between the source and the destination groups. _events.trigger_within_procedure( SETUP_REPLICATION, shard_id, source_group_id, destn_group_id, split_value, prune_limit, cmd )
def _restore_server(source_uuid, host, port, backup_image, mysqlclient_binary, config_file): """Restore the backup on the destination Server. :param source_uuid: The UUID of the source server. :param host: The hostname of the destination server. :param port: The port number of the destination server. :param userid: The User Name to be used to connect to the destn server. :param passwd: The password to be used to connect to the destn server. :param mysqldump_binary: The MySQL Dump Binary path. :param mysqlclient_binary: The MySQL Client Binary path. :param config_file: The complete path to the fabric configuration file. """ source_server = _server.MySQLServer.fetch(source_uuid) if not source_server: raise _errors.ServerError(SERVER_NOT_FOUND % source_uuid) #Build a backup image that will be used for restoring bk_img = _backup.BackupImage(backup_image) _backup.MySQLDump.restore_server(host, port, source_server.USER, source_server.PASSWD, bk_img, config_file, mysqlclient_binary) _LOGGER.debug("Done with restore of server with host = %s, port = %s" %\ (host, port,))