diff --git a/infrastructure/backup/image/resources/backup.bb b/infrastructure/backup/image/resources/backup.bb index 763f3a5..de8bfca 100755 --- a/infrastructure/backup/image/resources/backup.bb +++ b/infrastructure/backup/image/resources/backup.bb @@ -1,7 +1,6 @@ #!/usr/bin/env bb (require - '[babashka.tasks :as tasks] '[dda.backup.core :as bc] '[dda.backup.restic :as rc] '[dda.backup.postgresql :as pg] @@ -21,19 +20,15 @@ :pg-user (bc/env-or-file "POSTGRES_USER") :pg-password (bc/env-or-file "POSTGRES_PASSWORD")})) +(def aws-config {:aws-access-key-id (bc/env-or-file "AWS_ACCESS_KEY_ID") + :aws-secret-access-key (bc/env-or-file "AWS_SECRET_ACCESS_KEY")}) + (def dry-run {:dry-run true :debug true}) (defn prepare! [] - (tasks/shell ["mkdir" "/root/.aws"]) - (spit "/root/.aws/credentials" - (str "[default]\n" - "aws_access_key_id=" (bc/env-or-file "AWS_ACCESS_KEY_ID") "\n" - "aws_secret_access_key=" (bc/env-or-file "AWS_SECRET_ACCESS_KEY"))) - (tasks/shell ["chmod" "0600" "/root/.aws/credentials"]) - (tasks/shell ["chmod" "0600" "/root/.pgpass"] - (pg/create-pg-pass! db-config) - (tasks/shell ["export" "TEST=hallo"])) + (bc/create-aws-credentials! aws-config) + (pg/create-pg-pass! db-config)) (defn restic-repo-init! [] diff --git a/infrastructure/backup/image/resources/list-snapshots.bb b/infrastructure/backup/image/resources/list-snapshots.bb index dfe746f..349db38 100755 --- a/infrastructure/backup/image/resources/list-snapshots.bb +++ b/infrastructure/backup/image/resources/list-snapshots.bb @@ -1,7 +1,6 @@ #!/usr/bin/env bb (require - '[babashka.tasks :as tasks] '[dda.backup.core :as bc] '[dda.backup.restic :as rc]) @@ -13,13 +12,12 @@ (def db-config (merge restic-repo {:backup-path "pg-database"})) +(def aws-config {:aws-access-key-id (bc/env-or-file "AWS_ACCESS_KEY_ID") + :aws-secret-access-key (bc/env-or-file "AWS_SECRET_ACCESS_KEY")}) + (defn prepare! [] - (tasks/shell ["mkdir" "-p" "/root/.aws"]) - (spit "/root/.aws/credentials" - (str "[default]\n" - "aws_access_key_id=" (bc/env-or-file "AWS_ACCESS_KEY_ID") "\n" - "aws_secret_access_key=" (bc/env-or-file "AWS_SECRET_ACCESS_KEY") "\n"))) + (bc/create-aws-credentials! aws-config)) (defn list-snapshots! [] diff --git a/infrastructure/backup/image/resources/restore.bb b/infrastructure/backup/image/resources/restore.bb index b979dec..5a637a7 100755 --- a/infrastructure/backup/image/resources/restore.bb +++ b/infrastructure/backup/image/resources/restore.bb @@ -21,11 +21,15 @@ :pg-password (bc/env-or-file "POSTGRES_PASSWORD") :snapshot-id "latest"})) +(def aws-config {:aws-access-key-id (bc/env-or-file "AWS_ACCESS_KEY_ID") + :aws-secret-access-key (bc/env-or-file "AWS_SECRET_ACCESS_KEY")}) + (def dry-run {:dry-run true :debug true}) (defn prepare! [] - (pg/create-pg-pass! db-config)) + (pg/create-pg-pass! db-config) + (bc/create-aws-credentials! aws-config)) (defn restic-restore! []