config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

commit 020f32ea4b0a07f93d9ed25fddeb596abb466f10
parent 20393fc44537d7eb0a1e1c1ef6fb8fa77696cd0f
Author: dwrz <dwrz@dwrz.net>
Date:   Wed, 31 May 2023 14:19:46 +0000

Update backup script

Diffstat:
Mscripts/backup | 40++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/scripts/backup b/scripts/backup @@ -9,20 +9,9 @@ readonly HOSTS=( "mobile" "555.dwrz.net" "516.dwrz.net" + "srv" ) -backup-b2() { - local bucket id key destination - id="$(pass backblaze/duplicity/keyID)" - key="$(pass backblaze/duplicity/applicationKey)" - - env "B2_APPLICATION_KEY_ID"="${id}" "B2_APPLICATION_KEY"="${key}" \ - b2 sync "$@" - if [[ "$?" -ne 0 ]]; then - err "$0: failed b2 sync ${t} to ${destination}" - fi -} - backup-hosts() { local target="$1" @@ -43,19 +32,34 @@ backup-hosts() { main() { # Backup to B2. - local bucket + local id bucket key bucket="$(pass backblaze/bucket)" + id="$(pass backblaze/duplicity/keyID)" + key="$(pass backblaze/duplicity/applicationKey)" + # Config - backup-b2 --delete --excludeDirRegex="Signal" \ - "${HOME}/.config/" "b2://${bucket}/${HOSTNAME}/config" + env "B2_APPLICATION_KEY_ID"="${id}" "B2_APPLICATION_KEY"="${key}" \ + b2 sync --delete --excludeDirRegex="Signal" \ + "${HOME}/.config/" "b2://${bucket}/${HOSTNAME}/config" + if [[ "$?" -ne 0 ]]; then + err "$0: failed b2 sync config" + fi # Org - backup-b2 --delete --excludeDirRegex="email" \ - "${HOME}/org/" "b2://${bucket}/${HOSTNAME}/org" + env "B2_APPLICATION_KEY_ID"="${id}" "B2_APPLICATION_KEY"="${key}" \ + b2 sync --delete --excludeDirRegex="email" \ + "${HOME}/org/" "b2://${bucket}/${HOSTNAME}/org" + if [[ "$?" -ne 0 ]]; then + err "$0: failed b2 sync org" + fi # Projects - backup-b2 --delete "${HOME}/projects/" "b2://${bucket}/${HOSTNAME}/projects" + env "B2_APPLICATION_KEY_ID"="${id}" "B2_APPLICATION_KEY"="${key}" \ + b2 sync --delete "${HOME}/projects/" "b2://${bucket}/${HOSTNAME}/projects" + if [[ "$?" -ne 0 ]]; then + err "$0: failed b2 sync projects" + fi # Backup targets. for target in "${TARGETS[@]}"; do