dda-backup/infrastructure/backup/image/resources2/test-me.bb

45 lines
1.3 KiB
BlitzBasic
Raw Normal View History

2024-11-29 14:14:01 +00:00
#!/usr/bin/env bb
(println "initialized")
(require '[babashka.tasks :as tasks]
'[dda.backup.cred-rot :as cr]
'[dda.backup.restic :as rc]
'[dda.backup.postgresql :as pg])
(def restic-repo {:password-file "restic-pwd"
:restic-repository "restic-repo"})
(def file-config (merge restic-repo {:backup-path "files"
:files ["test-backup"]
:restore-target-directory "test-restore"}))
(def db-config (merge restic-repo {:backup-path "db"
:pg-db "mydb"
:pg-user "user"
:pg-password "password"}))
(def cred-config (merge restic-repo {:new-password-file "new-pw-file"}))
(def dry-run {:dry-run true :debug true})
(defn prepare!
[]
(spit "/tmp/file_password" "file-password")
(spit "restic-pwd" "ThePassword")
(tasks/shell "mkdir" "-p" "test-backup")
(spit "test-backup/file" "I was here")
(spit "new-pw-file" "newpassword")
(tasks/shell "mkdir" "-p" "test-restore")
(pg/create-pg-pass! db-config))
(defn restic-repo-init!
[]
(rc/init! restic-repo))
(prepare!)
(restic-repo-init!)
(cr/list-passwords! cred-config)
(cr/maybe-add-new! cred-config)
(cr/list-passwords! cred-config)