63 lines
1.5 KiB
Clojure
Executable file
63 lines
1.5 KiB
Clojure
Executable file
#!/usr/bin/env bb
|
|
|
|
(require '[babashka.tasks :as tasks]
|
|
'[dda.backup.restic :as rc]
|
|
'[dda.backup.backup :as bak]
|
|
'[dda.backup.restore :as rs])
|
|
|
|
(def restic-repo {:password-file "/restic-pwd"
|
|
:new-password-file "/new-restic-pwd"
|
|
:restic-repository "/restic-repo"
|
|
:debug true})
|
|
|
|
(def file-config (merge restic-repo {:backup-path "files"
|
|
:execution-directory "/var/backups/"
|
|
:files ["test-backup"]
|
|
:restore-target-directory "test-restore"}))
|
|
|
|
(def dry-run {:dry-run true :debug true})
|
|
|
|
(defn prepare!
|
|
[]
|
|
(spit "/tmp/file_password" "file-password")
|
|
|
|
(spit "/restic-pwd" "oldPassword")
|
|
(spit "/new-restic-pwd" "newPassword")
|
|
|
|
(tasks/shell "mkdir" "-p" "/var/backups/test-backup")
|
|
(spit "/var/backups/test-backup/file" "I was here")
|
|
(tasks/shell "mkdir" "-p" "/var/backups/test-restore"))
|
|
|
|
(defn restic-repo-init!
|
|
[]
|
|
(println "restic-repo-init!")
|
|
(rc/init! file-config))
|
|
|
|
(defn restic-backup!
|
|
[]
|
|
(println "restic-backup!")
|
|
(bak/backup-file! file-config))
|
|
|
|
(defn list-snapshots!
|
|
[]
|
|
(println "list-snapshots!")
|
|
(rc/list-snapshots! file-config))
|
|
|
|
|
|
(defn restic-restore!
|
|
[]
|
|
(println "restic-restore!")
|
|
(rs/restore-file! file-config))
|
|
|
|
(defn change-password!
|
|
[]
|
|
(println "change-password!")
|
|
(rc/change-password! file-config))
|
|
|
|
|
|
(prepare!)
|
|
(restic-repo-init!)
|
|
(restic-backup!)
|
|
(list-snapshots!)
|
|
(restic-restore!)
|
|
(change-password!)
|