Created
September 28, 2018 10:06
-
-
Save lastday154/b78aabd5b36c038fa6fc3a34c41d12ca to your computer and use it in GitHub Desktop.
backup ElasticSearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Backup ES | |
## Step 1: Create new index for index you want to backup | |
PUT /backup_test | |
```json | |
{ | |
"mappings": { | |
"faq": { | |
"properties": { | |
"category": { | |
"type": "text", | |
"fields": { | |
"keyword": { | |
"type": "keyword", | |
"ignore_above": 256 | |
} | |
} | |
}, | |
"id": { | |
"type": "text", | |
"fields": { | |
"keyword": { | |
"type": "keyword", | |
"ignore_above": 256 | |
} | |
} | |
}, | |
"params": { | |
"type": "object" | |
}, | |
"r": { | |
"type": "text", | |
"fields": { | |
"keyword": { | |
"type": "keyword", | |
"ignore_above": 256 | |
} | |
}, | |
"analyzer": "keyword" | |
}, | |
"intent": { | |
"type": "text", | |
"fields": { | |
"keyword": { | |
"type": "keyword", | |
"ignore_above": 256 | |
} | |
}, | |
"analyzer": "keyword" | |
}, | |
"language": { | |
"type": "text", | |
"analyzer": "keyword" | |
} | |
} | |
} | |
} | |
} | |
``` | |
## Step 2: Copy old index to new index | |
POST /_reindex | |
```json | |
{ | |
"source": { | |
"index": "test" | |
}, | |
"dest": { | |
"index": "backup_test" | |
} | |
} | |
``` | |
## Step 3: Delete old index | |
DELETE /test | |
## Step 4: Create again old index with new mapping data | |
PUT /test | |
```json | |
{ | |
"mappings": { | |
"faq": { | |
"properties": { | |
"category": { | |
"type": "text", | |
"fields": { | |
"keyword": { | |
"type": "keyword", | |
"ignore_above": 256 | |
} | |
} | |
}, | |
"id": { | |
"type": "text", | |
"fields": { | |
"keyword": { | |
"type": "keyword", | |
"ignore_above": 256 | |
} | |
} | |
}, | |
"params": { | |
"type": "object" | |
}, | |
"r": { | |
"type": "text", | |
"fields": { | |
"keyword": { | |
"type": "keyword", | |
"ignore_above": 256 | |
} | |
}, | |
"analyzer": "keyword" | |
}, | |
"intent": { | |
"type": "text", | |
"fields": { | |
"keyword": { | |
"type": "keyword", | |
"ignore_above": 256 | |
} | |
}, | |
"analyzer": "keyword" | |
}, | |
"language": { | |
"type": "text", | |
"analyzer": "keyword" | |
} | |
} | |
} | |
} | |
} | |
``` | |
## Step 5: Copy new index back to old index => done, you can choose to keep backup or delete it | |
POST /_reindex | |
```json | |
{ | |
"source": { | |
"index": "backup_test" | |
}, | |
"dest": { | |
"index": "test" | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment