2016-12-02 80 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));