diff --git a/backuper b/backuper index 839077f..13de763 100755 --- a/backuper +++ b/backuper @@ -1,21 +1,19 @@ #!/bin/env bash copy () { - while read Line; do - echo "Syncing $(basename $Line)" - rsync -ahAX -v --delete "$Line" $HOME/.local/backup - done <<< "$(cat $HOME/.config/rsync/sync-list)" + while read -r Line; do + echo "Syncing $(basename "$Line")" + rsync -ahAX -v --delete "$Line" "$HOME"/.local/backup + done <<< "$(cat "$HOME"/.config/rsync/sync-list)" } encrypt () { x=$(date +%d.%m.%y) - cd "$HOME/.local" - tar cv -I"zstd -19 -T0" -f "$HOME/.local/cloud/backup-$x.tar.zst" "backup" - read -p "Enter public key" pubKey - age -r $pubKey "$HOME/.local/cloud/backup-$x.tar.zst" > "$HOME/.local/cloud/backup-$x.tar.zst.age" - shred -uzn3 "$HOME/.local/cloud/backup-$x.tar.zst" + cd "$HOME/.local" || exit 1 + [ ! -d "$HOME/.local/cloud" ] || mkdir -p "$HOME/.local/cloud" + tar cv -I"zstd -19 -T0" "backup" | age -r "age1chj26ez7ucr2smkr8sfc9ddaa0fcyfljh5f5uk5kuyd8ctahs9wslfs708" > "$HOME/.local/cloud/backup-$x.tar.zst.age" } -[ -z "$@" ] && exit 1 -[ "$1" = "copy" ] && copy -[ "$1" = "encrypt" ] && encrypt +[ -z "$*" ] && exit 1 +[ "$1" = "copy" ] && copy && exit 0 +[ "$1" = "encrypt" ] && encrypt && exit 0