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 # install it
ADD resources /tmp/ ADD resources /tmp/
RUN /tmp/install.sh
ADD local/ /usr/local/lib/dda-backup 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 } > /dev/null
update-ca-certificates update-ca-certificates
/tmp/init.bb
cleanupDocker cleanupDocker
} }

View file

@ -3,4 +3,4 @@ FROM dda-backup:latest
# install it # install it
#ADD local/ /usr/local/lib/dda-backup #ADD local/ /usr/local/lib/dda-backup
ADD resources /tmp/ 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! (defn prepare!
[] []
(spit "file_password" "file-password") (spit "/tmp/file_password" "file-password")
(println (bc/env-or-file "file_password")) (println (bc/env-or-file "FILE_PASSWORD"))
(println (bc/env-or-file "env_password")) (println (bc/env-or-file "ENV_PASSWORD"))
(spit "restic-pwd" "ThePassword") (spit "restic-pwd" "ThePassword")
(tasks/shell "mkdir" "-p" "test-backup") (tasks/shell "mkdir" "-p" "test-backup")
(spit "test-backup/file" "I was here") (spit "test-backup/file" "I was here")
@ -43,6 +43,12 @@
(bak/backup-file! file-config) (bak/backup-file! file-config)
(bak/backup-db! (merge db-config dry-run))) (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! (defn restic-restore!
[] []
(rs/restore-file! file-config) (rs/restore-file! file-config)
@ -52,4 +58,5 @@
(prepare!) (prepare!)
(restic-repo-init!) (restic-repo-init!)
(restic-backup!) (restic-backup!)
(list-snapshots!)
(restic-restore!) (restic-restore!)

View file

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

View file

@ -43,3 +43,8 @@
[restic-config ::restic-config] [restic-config ::restic-config]
(let [config-w-defaults (merge core/default restic-config)] (let [config-w-defaults (merge core/default restic-config)]
(i/execute! (domain/forget-command config-w-defaults) config-w-defaults))) (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)))