diff --git a/shells/zshrc b/shells/zshrc index 8d16166..2a9ed49 100644 --- a/shells/zshrc +++ b/shells/zshrc @@ -347,6 +347,20 @@ hsh(){ echo pv "$FILE" \| pee $ARGS pv "$FILE" | pee $(echo $ARGS) } +enc() { + test -f README.md || echo "# enc\n## files" > README.md + while (( $# > 0 )) ; do + fn="$1" + uuid="$(uuidgen)" + shift + echo "Encrypting ($fn)..." + pv "$fn" | gpg -r stonewareslord -o "$uuid" -e - || (echo "Error encrypting $fn" >&2 ; continue) + echo "- \`$uuid\`: \`$fn\`" >> README.md || (echo "Error appending $fn to README.md" >&2 ; continue) + echo "Calculating sum of ($fn) in the background" + pv "$uuid" | sha512sum | perl -pe "s/-/$uuid/" >> SHA512SUMS || (echo "Error calculating sum of $uuid" >&2 ; continue) + rm "$fn" || (echo "Error removing $fn"; continue) + done +} rc(){ case $1 in z) vim ~/.zshrc;; diff --git a/zsh/borg.zsh b/zsh/borg.zsh new file mode 100644 index 0000000..ad65660 --- /dev/null +++ b/zsh/borg.zsh @@ -0,0 +1,23 @@ +REPO="aw:backup/backup.borg" +b-list() { + if [[ -z "$1" ]]; then + borg list "$REPO" + else + borg list "$REPO"::"$1" + fi +} +b-delete() { + if [[ ! -z "$1" ]]; then + borg delete "$REPO"::"$1" + fi +} +b-create() { + local BOOT="" + if (( $EUID != 0 )); then + echo -n "You aren't root, press enter to continue..." >&2 + fi + if [[ ! "$(hostname)" = "SGen" ]]; then + BOOT="/boot" + fi + borg create -vpsx --compression lzma,7 --exclude-from /home/stonewareslord/syncthing/me/backup/$(hostname)/nobackup aw:backup/backup.borg::$(hostname)-$(uuidgen) / "$BOOT" +}