- 安装elasticdump (预计20分钟 )
mkdir /data/nodejs
cd /data/nodejs
wget https://nodejs.org/dist/v10.16.2/node-v10.16.2-linux-x64.tar.xz
tar xvf node-v10.16.2-linux-x64.tar.xz -C /usr/local/
echo 'export PATH=/usr/local/node-v10.16.2-linux-x64/bin:$GOPATH/bin:$PATH' >> /etc/profile
npm install elasticdump -g
2.获取所有的索引 (10分钟)
curl -u elastic:'ES&ceshi720' 172.30.0.17:9200/_cat/indices >/tmp/indecies.txt
cat /tmp/indecies.txt |awk '{print $3}' >/tmp/all_indeciex.txt
3备份 (20G数据预计3个小时)
执行备份脚本/tmp/backup_es.sh备份
cat /tmp/backup_es.sh
#!/bin/bash mkdir -p /mnt/030901/ for indecies in `cat /tmp/all_indeciex.txt` do /usr/local/node-v10.16.2-linux-x64/bin/elasticdump --httpAuthFile=/tmp/a.txt --input=http://172.30.0.17:9200/$indecies --output=/mnt/030901/${indecies}data.json --type=data /usr/local/node-v10.16.2-linux-x64/bin/elasticdump --httpAuthFile=/tmp/a.txt --input=http://172.30.0.17:9200/$indecies --output=/mnt/030901/${indecies}mapping.json --type=mapping /usr/local/node-v10.16.2-linux-x64/bin/elasticdump --httpAuthFile=/tmp/a.txt --input=http://172.30.0.17:9200/$indecies --output=/mnt/030901/${indecies}settings.json --type=settings /usr/local/node-v10.16.2-linux-x64/bin/elasticdump --httpAuthFile=/tmp/a.txt --input=http://172.30.0.17:9200/$indecies --output=/mnt/030901/${indecies}analyzer.json --type=analyzer done
4.恢复 (预计2个小时)
执行恢复脚本/tmp/restore_es.sh恢复
cat /tmp/restore_es.sh
#!/bin/bash for indecies in `cat /tmp/all_indeciex.txt` do elasticdump --input=/mnt/030901/${indecies}settings.json --output=http://10.0.0.7:9200/$indecies --type=settings elasticdump --input=/mnt/030901/${indecies}mapping.json --output=http://10.0.0.7:9200/$indecies --type=mapping #elasticdump --input=/mnt/030901/${indecies}analyzer.json --output=http://10.0.0.7:9200/$indecies --type=analyzer elasticdump --input=/mnt/030901/${indecies}data.json --output=http://10.0.0.7:9200/$indecies --type=data done