diff options
author | Patrick Spek <p.spek@tyil.nl> | 2022-05-26 22:56:24 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2022-05-26 22:56:24 +0200 |
commit | ddf102d577a74b9b1ca51f2e95e3ee358f1565ca (patch) | |
tree | 7069c2309693c28d97d96983f747648c655e3519 /playbooks.d/backup-borg/share/backup.bash | |
parent | 358c9a47d7514d6e828843e4b630d1f7ac1c395e (diff) |
Make backup-borg playbook only install borg
Diffstat (limited to 'playbooks.d/backup-borg/share/backup.bash')
-rw-r--r-- | playbooks.d/backup-borg/share/backup.bash | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/playbooks.d/backup-borg/share/backup.bash b/playbooks.d/backup-borg/share/backup.bash deleted file mode 100644 index 0f9d5b7..0000000 --- a/playbooks.d/backup-borg/share/backup.bash +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash - -main() { - BORG_PASSPHRASE="$(bashtard var backup.key | awk -F= '{ print $NF }')" - - if [[ -z "$BORG_PASSPHRASE" ]] - then - return 3 - fi - - export BORG_PASSPHRASE - - backup_filesystem - backup_database_postgresql -} - -backup_filesystem() { - if ! command -v "borg" > /dev/null 2>&1 - then - return 4 - fi - - if ! command -v "borgmatic" > /dev/null 2>&1 - then - return 4 - fi - - borgmatic -} - -backup_database_postgresql() { - if ! command -v "psql" > /dev/null 2>&1 - then - return 4 - fi - - if ! command -v "pg_dump" > /dev/null 2>&1 - then - return 4 - fi - - local remote - - remote="$(bashtard var backup.db.postgresql.remote_base)" - PGUSER="$(bashtard var backup.db.postgresql.user | awk -F= '{ print $NF }')" - - export PGUSER - - while read -r database - do - [[ $database == "postgres" ]] && continue - [[ $database =~ template* ]] && continue - - pg_dump "$database" \ - | borg create "$remote-$database::$(date -u +%FT%TZ)" - done < <(psql -AXt -d template1 -c "SELECT datname FROM pg_database") -} - -main "$@" |