我正在使用 python boto 编写 AWS Elasticsearch 快照备份/恢复实现。我能够将 AWS S3 注册为 ES 快照存储库。这是我的创建快照功能的片段。
import boto
import urllib
from boto.connection import AWSAuthConnection
class ESConnection(AWSAuthConnection):
def __init__(self, region, **kwargs):
super(ESConnection, self).__init__(**kwargs)
self._set_auth_region_name(region)
self._set_auth_service_name("es")
def _required_auth_capability(self):
return ['hmac-v4']
def create_snapshots(profile, region_name, es_host,total_snapshots_to_keep):
.
.
.
url = "/_snapshot/es_repository/{}?".format(snapshot_name)
flag = urllib.urlencode({'wait_for_completion':'true'})
resp = client.make_request(method='PUT',
path=urllib.quote("{}{}".format(url,flag)),
data='{"indices": "' + audit_index_name + '", "ignore_unavailable": true, "include_global_state": false}')
主要问题似乎在上面的片段中,我正在尝试为
{u'status': 400, u'error': {u'root_cause': [{u'reason': u'[es_repository:v4_2017_03_27_snapshot?wait_for_completion=true] 无效的快照名称[v4_2017_03_27_snapshot?wait_for_completion=true],不能包含以下字符 [\, /, *, ?, ", <, >, |, , ,]', u'type': u'invalid_snapshot_name_exception'}], u'type': u'invalid_snapshot_name_exception', u' reason': u'[es_repository:v4_2017_03_27_snapshot?wait_for_completion=true] 无效的快照名称[v4_2017_03_27_snapshot?wait_for_completion=true],不能包含以下字符[\, /, *, ?, ", <, >, |, , , ]'}}
它将我的实际快照名称和 wait_for_completion 标志完全作为快照名称
无效的快照名称 [v4_2017_03_27_snapshot?wait_for_completion=true],不得包含以下字符 [\, /, *, ?, ", <, >, |, , ,]'}}
你能帮我指出我在为弹性搜索构建 url 时做错的地方吗?或者有没有更好的方法来实现这一点?