#!/usr/bin/env bb (require '[babashka.tasks :as tasks] '[dda.backup.management :as mgm] '[dda.backup.postgresql :as ps] '[dda.backup.backup :as bak] '[dda.backup.restore :as rs]) (def restic-repo {:password-file "restic-pwd" :restic-repository "restic-repo"}) (defn prepare! [] (ps/create-pg-pass! (merge restic-repo {:backup-path "db" :pg-db "mydb" :pg-user "user" :pg-password "password"}))) (defn restic-repo-init! [] (spit "restic-pwd" "ThePassword") (mgm/init! (merge restic-repo {:backup-path "files"})) (mgm/init! (merge restic-repo {:backup-path "db" :dry-run true :debug true}))) (defn restic-backup! [] (tasks/shell "mkdir" "-p" "test-backup") (spit "test-backup/file" "I was here") (bak/backup! (merge restic-repo {:backup-path "files" :files ["test-backup"]}))) (defn restic-restore! [] (tasks/shell "mkdir" "-p" "test-restore") (rs/restore! (merge restic-repo {:backup-path "files" :target-directory "test-restore"}))) (prepare!) (restic-repo-init!) (restic-backup!) (restic-restore!)