From 22836f3210dd5fa91886af3287c0a51c1ee90585 Mon Sep 17 00:00:00 2001 From: "flyingscorpio@arch-desktop" Date: Sun, 18 Oct 2020 22:23:05 +0200 Subject: [PATCH 1/2] Make borg a little bit less personal --- borg_backup.sh | 6 +++--- pacman_hooks/borg_backup.hook | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/borg_backup.sh b/borg_backup.sh index f12eccb..a08c7e2 100755 --- a/borg_backup.sh +++ b/borg_backup.sh @@ -1,10 +1,10 @@ -#!/bin/sh +#!/bin/bash ### ### borg_backup.sh ### ### Usage: -### "$0" [-f] +### borg_backup.sh [-f] ### ### Options: ### -f Force an update, even if one was already made today. @@ -16,7 +16,7 @@ print_help() { awk -F'### ' '/^###/ { print $2 }' "$0" } -cache_file='/home/flyingscorpio/.cache/borg_backup_hook_last_executed' +cache_file="$HOME/.cache/borg_backup_hook_last_executed" stat_cache_file() { # We only want this file to be executed at most once per day, so we stat a cache # file before running the rest of the code diff --git a/pacman_hooks/borg_backup.hook b/pacman_hooks/borg_backup.hook index 38ffb19..cb34793 100644 --- a/pacman_hooks/borg_backup.hook +++ b/pacman_hooks/borg_backup.hook @@ -6,7 +6,7 @@ Type = Package Target = * [Action] -Description = Update to lime2 +Description = Borg backup When = PreTransaction -Exec = /bin/sh /home/flyingscorpio/SetupCockpit/borg_backup.sh +Exec = /home/flyingscorpio/SetupCockpit/borg_backup.sh Depends = borg From b7634be0a5340d2b73561b0b4aead8c877eff96a Mon Sep 17 00:00:00 2001 From: "flyingscorpio@arch-desktop" Date: Sun, 18 Oct 2020 22:46:25 +0200 Subject: [PATCH 2/2] Remove password from borg script --- borg_backup.sh | 3 ++- pacman_hooks/borg_backup.hook | 2 +- secrets.template | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/borg_backup.sh b/borg_backup.sh index a08c7e2..ef9159e 100755 --- a/borg_backup.sh +++ b/borg_backup.sh @@ -44,7 +44,8 @@ touch "$cache_file" BORG_REPO=ssh://flyingscorpio@2px.info:22/~/"$(hostname)".borg export BORG_REPO -export BORG_PASSPHRASE='ribosome66' +BORG_PASSPHRASE="$BORG_PASSPHRASE" +export BORG_PASSPHRASE # some helpers and error handling: info() { printf "\n%s %s\n\n" "$(date)" "$*" >&2; } diff --git a/pacman_hooks/borg_backup.hook b/pacman_hooks/borg_backup.hook index cb34793..9dc92df 100644 --- a/pacman_hooks/borg_backup.hook +++ b/pacman_hooks/borg_backup.hook @@ -8,5 +8,5 @@ Target = * [Action] Description = Borg backup When = PreTransaction -Exec = /home/flyingscorpio/SetupCockpit/borg_backup.sh +Exec = source /home/flyingscorpio/SetupCockpit/secrets && /home/flyingscorpio/SetupCockpit/borg_backup.sh Depends = borg diff --git a/secrets.template b/secrets.template index 00cce75..02f52fe 100644 --- a/secrets.template +++ b/secrets.template @@ -1,3 +1,4 @@ # secrets - is sourced by some commands - this is a template SETUP_COCKPIT_EMAIL='' +BORG_PASSPHRASE=''