add additional restore cleanup option
This commit is contained in:
parent
e7c0b75166
commit
cc06d43d3e
2 changed files with 27 additions and 5 deletions
|
@ -9,11 +9,13 @@
|
|||
|
||||
(s/def ::restore-target-directory string?)
|
||||
(s/def ::snapshot-id string?)
|
||||
(s/def ::clean-up-element string?)
|
||||
(s/def ::clean-up-elements (s/coll-of ::clean-up-element))
|
||||
|
||||
(s/def ::restore-file-config
|
||||
(s/merge ::rd/restic-config
|
||||
(s/keys :req-un [::restore-target-directory
|
||||
::snapshot-id])))
|
||||
(s/keys :req-un [::restore-target-directory ::snapshot-id]
|
||||
:opt-un [::clean-up-elements])))
|
||||
|
||||
(s/def ::restore-db-config
|
||||
(s/merge ::pd/pg-config
|
||||
|
@ -22,8 +24,12 @@
|
|||
|
||||
(defn-spec restore-dir-command ::cd/commands
|
||||
[config ::restore-file-config]
|
||||
(let [{:keys [restore-target-directory snapshot-id]} config]
|
||||
[["rm" "-rf" restore-target-directory]
|
||||
(let [{:keys [restore-target-directory snapshot-id clean-up-elements]} config]
|
||||
[(if (contains? config :clean-up-elements)
|
||||
(into
|
||||
["rm" "-rf"]
|
||||
(map #(str restore-target-directory "/" %) clean-up-elements))
|
||||
["rm" "-rf" restore-target-directory])
|
||||
(rd/repo-command config ["restore" snapshot-id "--target" restore-target-directory] false)]))
|
||||
|
||||
(defn-spec restore-db-command ::cd/commands
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
(st/instrument `cut/restore-dir-command)
|
||||
(st/instrument `cut/restore-db-command)
|
||||
|
||||
(deftest should-calculate-restore-dir
|
||||
(deftest should-calculate-restore-dir-command
|
||||
(is (= [["rm" "-rf" "dir-to-backup"]
|
||||
["restic"
|
||||
"-r"
|
||||
|
@ -22,6 +22,22 @@
|
|||
:restore-target-directory "dir-to-backup"
|
||||
:days-to-keep 39
|
||||
:months-to-keep 3
|
||||
:snapshot-id "latest"})))
|
||||
(is (= [["rm" "-rf" "dir-to-backup/file" "dir-to-backup/folder/"]
|
||||
["restic"
|
||||
"-r"
|
||||
"repo/dir-at-repo"
|
||||
"-v"
|
||||
"restore"
|
||||
"latest"
|
||||
"--target"
|
||||
"dir-to-backup"]]
|
||||
(cut/restore-dir-command {:restic-repository "repo"
|
||||
:backup-path "dir-at-repo"
|
||||
:restore-target-directory "dir-to-backup"
|
||||
:clean-up-elements ["file" "folder/"]
|
||||
:days-to-keep 39
|
||||
:months-to-keep 3
|
||||
:snapshot-id "latest"}))))
|
||||
|
||||
(deftest should-calculate-restore-db
|
||||
|
|
Loading…
Add table
Reference in a new issue