User Tools

Site Tools


wiki:elasticsearch_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wiki:elasticsearch_commands [2022/12/09 09:59] – [Restore snapshot] add info about snapshot missing antisawiki:elasticsearch_commands [2023/01/11 17:03] (current) – [Restore snapshot] add restore single index antisa
Line 12: Line 12:
 Replace "twitter" with your index name.  Replace "twitter" with your index name. 
  
 +==== Delete all indices ====
 +
 +  curl -X DELETE 'http://localhost:9200/_all'
 ===== Create snapshot ===== ===== Create snapshot =====
 Register repo first: Register repo first:
Line 30: Line 33:
  
   curl -X PUT "localhost:9200/_snapshot/es_backup/ztest?wait_for_completion=true&pretty"   curl -X PUT "localhost:9200/_snapshot/es_backup/ztest?wait_for_completion=true&pretty"
 +
 +<WRAP center round tip 60%>
 +To create single index snapshot use
 +<code>
 +curl -X PUT "localhost:9200/_snapshot/default_backup/myindex_backup?wait_for_completion=true&pretty" -H 'Content-Type: application/json' -d'
 +{
 +  "indices": "coolindex"
 +}'
 +</code>
 +</WRAP>
  
 The backup folder is created in ///opt/backup/elasticsearch///. The backup folder is created in ///opt/backup/elasticsearch///.
Line 47: Line 60:
 When you transfer it to another server unzip it, make sure that the owner is elasticsearch on the folder and then create the snapshot repository with command above, otherwise you won't see it when trying to list the snaphots. When you transfer it to another server unzip it, make sure that the owner is elasticsearch on the folder and then create the snapshot repository with command above, otherwise you won't see it when trying to list the snaphots.
  
-List the snapshots with above command. If you get an error like: +List the snapshots with above command. 
- +
-  "snapshot_missing_exception" +
- +
-Delete the snapshot repo +
- +
-  curl -X DELETE -u undefined:$ESPASS "localhost:9200/_snapshot/es_backup?pretty +
- +
-and try listing again.+
  
 After this do the restore with snapshot name you want: After this do the restore with snapshot name you want:
  
   curl -s -X POST "localhost:9200/_snapshot/es_backup/snapshot-12/_restore"    curl -s -X POST "localhost:9200/_snapshot/es_backup/snapshot-12/_restore" 
 +
 +<WRAP center round tip 60%>
 +To restore single index use
 +<code>
 +curl -s -X POST "localhost:9200/_snapshot/myes_bak/snapshot-2023-01-11/_restore" -H 'Content-Type: application/json' -d'
 +{
 +  "indices": "niceindex"
 +}'
 +</code>
 +</WRAP>
  
 If you get an [[https://github.com/elastic/elasticsearch/issues/78320|error]] that an index exist, like with the system index ''.geoip_databases'', you can restore the system indices from the snapshot as well with If you get an [[https://github.com/elastic/elasticsearch/issues/78320|error]] that an index exist, like with the system index ''.geoip_databases'', you can restore the system indices from the snapshot as well with
  
-  curl -s -X POST "localhost:9200/_snapshot/es_backup/snapshot-12/_restore" -H 'Content-Type: application/json' -d +  curl -s -X POST "localhost:9200/_snapshot/es_backup/snapshot-12/_restore" -H 'Content-Type: application/json' -d \ 
-  {+  '{
   "include_global_state": true   "include_global_state": true
-  }+  }'
  
 ==== Tested on ==== ==== Tested on ====
Line 76: Line 91:
 ====== References ====== ====== References ======
   * https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshots-restore-snapshot.html   * https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshots-restore-snapshot.html
 +  * https://opster.com/guides/elasticsearch/how-tos/elasticsearch-snapshot/
 +
  
wiki/elasticsearch_commands.1670576360.txt.gz · Last modified: 2022/12/09 09:59 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki