33 lines
923 B
Clojure
Executable file
33 lines
923 B
Clojure
Executable file
#! /usr/bin/env bb
|
|
|
|
(ns restic-management
|
|
(:require
|
|
[clojure.spec.alpha :as s]
|
|
[clojure.java.io :as io]
|
|
[clojure.edn :as edn]))
|
|
|
|
(s/def ::state string?)
|
|
|
|
(s/def ::backup-repository-state
|
|
(s/keys :req-un [::state]))
|
|
|
|
(def state {:state ""})
|
|
|
|
(defn store-backup-repository-state [s]
|
|
(spit "backup-repository-state.edn" s))
|
|
|
|
(defn read-backup-repository-state []
|
|
(try
|
|
(with-open [r (io/reader "backup-repository-state.edn")]
|
|
(edn/read (java.io.PushbackReader. r)))
|
|
|
|
(catch java.io.IOException e
|
|
(printf "Couldn't open '%s': %s\n" "backup-repository-state.edn" (.getMessage e)))
|
|
(catch RuntimeException e
|
|
(printf "Error parsing edn file '%s': %s\n" "backup-repository-state.edn" (.getMessage e)))))
|
|
|
|
(println (read-backup-repository-state))
|
|
|
|
(println (:state (read-backup-repository-state)))
|
|
|
|
(println (s/valid? ::backup-repository-state (read-backup-repository-state)))
|