integrate in first c4k

This commit is contained in:
Michael Jerger 2024-08-22 18:06:30 +02:00
parent 3095050ebf
commit f8fa593204
8 changed files with 33 additions and 13 deletions

View file

@ -2,5 +2,5 @@ FROM ubuntu:24.04
# install it
ADD resources /tmp/
RUN /tmp/install.sh
ADD local/ /usr/local/lib/dda-backup
RUN /tmp/install.sh

View file

@ -0,0 +1,3 @@
{:deps {org.clojure/spec.alpha {:mvn/version "0.4.233"}
orchestra/orchestra {:mvn/version "2021.01.01-1"}
org.domaindrivenarchitecture/dda-backup {:local/root "/usr/local/lib/dda-backup"}}}

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bb
(println "initialized")

View file

@ -23,6 +23,7 @@ function main() {
} > /dev/null
update-ca-certificates
/tmp/init.bb
cleanupDocker
}

View file

@ -3,4 +3,4 @@ FROM dda-backup:latest
# install it
#ADD local/ /usr/local/lib/dda-backup
ADD resources /tmp/
RUN ENV_PASSWORD=env-password /tmp/test.bb
RUN ENV_PASSWORD=env-password FILE_PASSWORD_FILE=/tmp/file_password /tmp/test.bb

View file

@ -24,9 +24,9 @@
(defn prepare!
[]
(spit "file_password" "file-password")
(println (bc/env-or-file "file_password"))
(println (bc/env-or-file "env_password"))
(spit "/tmp/file_password" "file-password")
(println (bc/env-or-file "FILE_PASSWORD"))
(println (bc/env-or-file "ENV_PASSWORD"))
(spit "restic-pwd" "ThePassword")
(tasks/shell "mkdir" "-p" "test-backup")
(spit "test-backup/file" "I was here")
@ -43,6 +43,12 @@
(bak/backup-file! file-config)
(bak/backup-db! (merge db-config dry-run)))
(defn list-snapshots!
[]
(rc/list-snapshots! file-config)
(rc/list-snapshots! (merge db-config dry-run)))
(defn restic-restore!
[]
(rs/restore-file! file-config)
@ -52,4 +58,5 @@
(prepare!)
(restic-repo-init!)
(restic-backup!)
(list-snapshots!)
(restic-restore!)

View file

@ -15,9 +15,10 @@
(defn-spec env-or-file string?
[name string?]
(let [name-upper (st/upper-case name)
name-lower (st/lower-case name)
from-env (System/getenv name-upper)]
(if (some? from-env)
from-env
(slurp name-lower))))
(let [from-env (System/getenv name)
name-from-file (System/getenv (str name "_FILE"))]
(cond
(some? from-env) from-env
(some? name-from-file) (slurp name-from-file)
:else (throw ( RuntimeException.
(str "Environment: [" name "," name-from-file "] was missing." ))))))

View file

@ -43,3 +43,8 @@
[restic-config ::restic-config]
(let [config-w-defaults (merge core/default restic-config)]
(i/execute! (domain/forget-command config-w-defaults) config-w-defaults)))
(defn-spec list-snapshots! nil?
[restic-config ::restic-config]
(let [config-w-defaults (merge core/default restic-config)]
(i/execute! (domain/list-snapshot-command config-w-defaults) config-w-defaults)))