-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup.clj
40 lines (32 loc) · 1 KB
/
backup.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(ns rubber.backup
"Backup Elasticsearch indices using snapshot/restore APIs check:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"
(:require [rubber.core :refer (call ok)]))
(defn create-repository
"Create a snapshot repository"
[repo location]
(ok (call :put [:_snapshot repo] {:type "fs" :settings {:location location}})))
(defn get-repository
"Get repository information"
[repo]
(call :get [:_snapshot repo]))
(defn create-snapshot
"snapshot Elasticsearch"
[repo snap]
(ok (call :put [:_snapshot repo snap] {})))
(defn get-snapshot
"Get a snapshot information"
[repo snap]
(:body (call :get [:_snapshot repo snap])))
(defn list-repositories
"List available repositories"
[]
(:body (call :get [:_snapshot :_all])))
(defn list-snapshots
"List available repositories"
[repo]
(:body (call :get [:_snapshot repo :_all])))
(defn restore-snapshot
"Restore a snapshot "
[repo snap]
(ok (call :post [:_snapshot repo snap :_restore])))