Added enc() and borg functions

This commit is contained in:
Austen Adler 2016-08-29 11:54:43 -04:00
parent dfed944ee1
commit 9c4ecb203d
No known key found for this signature in database
GPG Key ID: 7ECEE590CCDFE3F1
2 changed files with 37 additions and 0 deletions

View File

@ -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;;

23
zsh/borg.zsh Normal file
View File

@ -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"
}