Added enc() and borg functions
This commit is contained in:
parent
dfed944ee1
commit
9c4ecb203d
14
shells/zshrc
14
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;;
|
||||
|
23
zsh/borg.zsh
Normal file
23
zsh/borg.zsh
Normal 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"
|
||||
}
|
Loading…
Reference in New Issue
Block a user