2016-12-02 82 views
0

我需要从elasticsearch备份我的索引,然后恢复它。我找不到一个例子。我试着写是这样的:如何在Nest中创建快照?

public virtual ISnapshotResponse BackUp() 
{ 
    return _client.Snapshot("D:\\snapshots", "1", descriptor => descriptor 
     .Indices(_indexString) 
     .IncludeGlobalState(false)); 
} 

但它也有因为repository参数无效响应。

请帮我创建一个快照,然后恢复我的索引。

+0

您需要先注册Elasticsearch的快照库,然后才能拍摄快照。请参阅https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html。 –

回答

0

步骤:1

正义: 例如

PUT /_snapshot/es_backup 
{ 
    "type": "fs", 
    "settings": { 
     "location": "C:/SIEM/New/elasticsearch-5.4.3/es_backup", 
     "compress": true 
    } 
} 

步骤:2

ESConfiguration elasticsearch.ym升文件设置备份路径: 例如

path.repo: ["C:/SIEM/New/elasticsearch-5.4.3/es_backup"] 

步骤:3

C#: 例如

var uri = new Uri("http://localhost:9200"); 
       var settings = new ConnectionSettings(uri); 
       var client = new ElasticClient(settings); 

       var result = client.Snapshot("es_backup", "snapshot_4", x => x.WaitForCompletion(true));