From 23ec2c6106976791a360cdda459ccd869e94a28c Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 23 Aug 2024 11:39:59 +0200 Subject: [PATCH] test the integration --- .../backup/image/resources/backup.bb | 20 ++++++++++++++----- .../backup/image/resources/list-snapshots.bb | 20 +++++++++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/infrastructure/backup/image/resources/backup.bb b/infrastructure/backup/image/resources/backup.bb index b517543..763f3a5 100755 --- a/infrastructure/backup/image/resources/backup.bb +++ b/infrastructure/backup/image/resources/backup.bb @@ -1,9 +1,11 @@ #!/usr/bin/env bb -(require '[dda.backup.core :as bc] - '[dda.backup.restic :as rc] - '[dda.backup.postgresql :as pg] - '[dda.backup.backup :as bak]) +(require + '[babashka.tasks :as tasks] + '[dda.backup.core :as bc] + '[dda.backup.restic :as rc] + '[dda.backup.postgresql :as pg] + '[dda.backup.backup :as bak]) (def restic-repo {:password-file (bc/env-or-file "RESTIC_PASSWORD_FILE") :restic-repository (bc/env-or-file "RESTIC_REPOSITORY")}) @@ -23,7 +25,15 @@ (defn prepare! [] - (pg/create-pg-pass! db-config)) + (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"])) (defn restic-repo-init! [] diff --git a/infrastructure/backup/image/resources/list-snapshots.bb b/infrastructure/backup/image/resources/list-snapshots.bb index 225d618..dfe746f 100755 --- a/infrastructure/backup/image/resources/list-snapshots.bb +++ b/infrastructure/backup/image/resources/list-snapshots.bb @@ -1,14 +1,30 @@ #!/usr/bin/env bb -(require '[dda.backup.core :as bc] - '[dda.backup.restic :as rc]) +(require + '[babashka.tasks :as tasks] + '[dda.backup.core :as bc] + '[dda.backup.restic :as rc]) (def restic-repo {:password-file (bc/env-or-file "RESTIC_PASSWORD_FILE") :restic-repository (bc/env-or-file "RESTIC_REPOSITORY")}) +(def file-config (merge restic-repo {:backup-path "files"})) + + +(def db-config (merge restic-repo {:backup-path "pg-database"})) + +(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"))) + (defn list-snapshots! [] (rc/list-snapshots! file-config) (rc/list-snapshots! db-config)) +(prepare!) (list-snapshots!)