dda-backup/infrastructure/backup/test/resources/test.bb

42 lines
1.3 KiB
BlitzBasic
Raw Normal View History

2024-08-19 06:55:14 +00:00
#!/usr/bin/env bb
(require '[babashka.tasks :as tasks]
'[dda.backup.management :as mgm]
2024-08-20 05:56:13 +00:00
'[dda.backup.postgresql :as ps]
2024-08-19 06:55:14 +00:00
'[dda.backup.backup :as bak]
'[dda.backup.restore :as rs])
2024-08-20 05:56:13 +00:00
(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"})))
2024-08-19 06:55:14 +00:00
(defn restic-repo-init!
[]
(spit "restic-pwd" "ThePassword")
2024-08-20 05:56:13 +00:00
(mgm/init! (merge restic-repo {:backup-path "files"}))
(mgm/init! (merge restic-repo {:backup-path "db" :dry-run true :debug true})))
2024-08-19 06:55:14 +00:00
(defn restic-backup!
[]
(tasks/shell "mkdir" "-p" "test-backup")
(spit "test-backup/file" "I was here")
2024-08-20 05:56:13 +00:00
(bak/backup! (merge restic-repo {:backup-path "files"
:files ["test-backup"]})))
2024-08-19 06:55:14 +00:00
(defn restic-restore!
[]
(tasks/shell "mkdir" "-p" "test-restore")
2024-08-20 05:56:13 +00:00
(rs/restore! (merge restic-repo {:backup-path "files"
:target-directory "test-restore"})))
2024-08-19 06:55:14 +00:00
2024-08-20 05:56:13 +00:00
(prepare!)
2024-08-19 06:55:14 +00:00
(restic-repo-init!)
(restic-backup!)
(restic-restore!)