(ns dda.backup.backup (:require [orchestra.core :refer [defn-spec]] [clojure.spec.alpha :as s] [dda.backup.core.domain :as cd] [dda.backup.backup.domain :as domain] [dda.backup.core :as core] [dda.backup.management :as mgm] [dda.backup.infrastructure :as i])) (s/def ::config (s/keys :req-un [::domain/files ::cd/restic-repository ::cd/backup-path] :opt-un [::cd/certificate-file ::cd/password-file ::cd/days-to-keep ::cd/months-to-keep ::cd/directory ::cd/dry-run ::cd/debug])) (defn-spec backup! nil? [config ::config] (let [config-w-defaults (merge core/default config)] (mgm/unlock! config-w-defaults) (i/execute! (domain/backup-files-command config-w-defaults) config-w-defaults) (mgm/forget! config-w-defaults) ))