c4k-forgejo/infrastructure/backup/test/resources/test.bb

29 lines
786 B
BlitzBasic
Raw Normal View History

2024-08-16 14:29:34 +00:00
#!/usr/bin/env bb
(require '[babashka.tasks :as tasks]
2024-08-16 16:11:22 +00:00
'[dda.backup.management :as mgm]
'[dda.backup.backup :as bak])
2024-08-16 14:29:34 +00:00
(defn restic-repo-init!
[]
(spit "restic-pwd" "ThePassword")
(mgm/init! {:password-file "restic-pwd"
:restic-repository "restic-repo"}))
(defn restic-backup!
[]
(tasks/shell "mkdir" "-p" "test-backup")
(spit "test-backup/file" "I was here")
2024-08-16 16:11:22 +00:00
(bak/backup! {:password-file "restic-pwd"
:restic-repository "restic-repo"}
["test-backup"]))
2024-08-16 14:29:34 +00:00
(defn restic-restore!
[]
(tasks/shell "mkdir" "-p" "test-restore")
2024-08-16 16:11:22 +00:00
(tasks/shell "restic" "restore" "--password-file" "restic-pwd" "--repo" "restic-repo" "--target" "test-restore" "latest"))
2024-08-16 14:29:34 +00:00
(restic-repo-init!)
(restic-backup!)
(restic-restore!)