Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
sunbird-devops-graylog
Commits
567c43f4
Commit
567c43f4
authored
6 years ago
by
kartish
Browse files
Options
Download
Patches
Plain Diff
Issue #000 fix: backup and restore shell scripts for elasticsearch
parent
e533153c
release-1.5.0
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
deploy/backup_elasticsearch.sh
+15
-14
deploy/backup_elasticsearch.sh
deploy/restore_elasticsearch.sh
+18
-0
deploy/restore_elasticsearch.sh
with
33 additions
and
14 deletions
+33
-14
deploy/backup_elasticsearch.sh
+
15
−
14
View file @
567c43f4
#!/bin/sh
backup_path
=
/etc/elasticsearch/backup
es_ip
=
10.2.1.5
es_ip
=
$(
ip route get 8.8.8.8 |
awk
'{print $NF; exit}'
)
if
[
-
f
$backup_path
]
if
[
-
d
$backup_path
]
;
then
echo
"directory exists"
echo
"directory exists"
else
mkdir
-p
/etc/elasticsearch/backup
mkdir
-p
/etc/elasticsearch/backup
fi
cat
>>
/etc/elasticsearch/es-1/elasticsearch.yml
<<
EOF
temp
=
$(
grep
"path.repo:"
/etc/elasticsearch/es-1/elasticsearch.yml
)
if
[
$?
-ne
0
]
;
then
cat
>>
/etc/elasticsearch/es-1/elasticsearch.yml
<<
EOF
path.repo: ["/etc/elasticsearch/backup"]
EOF
/usr/share/elasticsearch/bin/elasticsearch
\
-p
/var/run/elasticsearch/10.2.1.5-es-1/elasticsearch.pid
\
--quiet
\
-Edefault
.path.logs
=
${
LOG_DIR
}
\
-Edefault
.path.data
=
${
DATA_DIR
}
\
-Edefault
.path.conf
=
${
CONF_DIR
}
fi
chown
-R
elasticsearch:elasticsearch
$backup_path
echo
$es_ip
curl
-XPUT
'
http://$es_ip:9200/_snapshot/my_backup
'
-d
{
curl
-XPUT
http://
$es_ip
:9200/_snapshot/my_backup
-d
'
{
"type": "fs",
"settings": {
"location"
:
"
$backup_path
"
,
"location": "
'
$backup_path
'
",
"compress": true
}
}'
curl -XPUT "$es_ip:9200/_snapshot/my_backup/snapshot_1?wait_for_completion=true"
timestamp
=
`
date
'+%d_%m_%Y%H%M%S'
`
curl
-XPUT
http://
$es_ip
:9200/_snapshot/my_backup/snapshot_
$timestamp
?wait_for_completion
=
true
\ No newline at end of file
This diff is collapsed.
Click to expand it.
deploy/restore_elasticsearch.sh
0 → 100644
+
18
−
0
View file @
567c43f4
#!/bin/sh
backup_path
=
/etc/elasticsearch/backup
es_ip
=
$(
ip route get 8.8.8.8 |
awk
'{print $NF; exit}'
)
curl 172.31.0.239:9200/_cat/indices?v |
awk
'{print $3}'
|
awk
'NR>1'
>
~/index.txt
while
read
line
;
do
curl
-XDELETE
http://
$es_ip
:9200/
$line
done
< ~/index.txt
rm
-rf
~/index.txt
snapshot_id
=
$1
curl
-XPOST
"http://
$es_ip
:9200/_snapshot/my_backup/
$snapshot_id
/_restore"
echo
$(
curl http://
$es_ip
:9200/_cat/indices?v
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets