This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/common/bin/backupify

27 lines
696 B
Plaintext
Raw Normal View History

2021-02-18 13:26:10 -06:00
#!/usr/bin/env fish
set host rift
set dir /storage/daniel/backups
set ext .tar.zstd.gpg
if not set -q argv[1]
echo "No directory provided"
exit 2
end
if not test -d $argv[1]
echo "Invalid directory given: $argv[1]"
exit 1
end
set fn (date +%Y%m%d_%H%M%S)(basename $argv[1])
2021-02-18 13:30:21 -06:00
pushd (dirname $argv[1])
2021-03-25 09:29:48 -05:00
# TODO: progress bar/status?
echo "Streaming PGP encrypted backup of $argv[1] to host rift via ssh at $dir/$fn$ext..."
2021-02-18 13:30:21 -06:00
tar cvf - (basename $argv[1]) 2>/dev/null |
2021-02-18 13:26:10 -06:00
zstd --ultra -T2 -22 |
gpg --encrypt --recipient daniel@lyte.dev |
ssh $host "cat - > $dir/$fn$ext"
2021-02-18 13:30:21 -06:00
popd
2021-02-18 13:26:10 -06:00
# TODO: checksum?
echo "Uploaded to host rift via ssh at $dir/$fn$ext"
2021-03-25 09:29:48 -05:00
echo ' Run `unbackupify '$fn$ext'` to restore!'