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