Work on backups script

This commit is contained in:
Daniel Flanagan 2021-02-18 13:26:10 -06:00
parent 2ffe54a061
commit 7cdad89918
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
5 changed files with 54 additions and 0 deletions

View file

@ -169,6 +169,7 @@ client.unfocused #111111 #111111 #ffffff #111111 #111111
exec_always 'killall kanshi; kanshi'
exec mako
exec pipewire
exec_always notify-send -a "Sway" -i ~/.wallpaper "Sway configuration loaded."
bar {

21
bin/backupify Executable file
View file

@ -0,0 +1,21 @@
#!/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])
tar -cvf - $argv[1] 2>/dev/null |
zstd --ultra -T2 -22 |
gpg --encrypt --recipient daniel@lyte.dev |
ssh $host "cat - > $dir/$fn$ext"
# TODO: checksum?
echo "Uploaded to host rift via ssh at $dir/$fn$ext"

14
bin/bupstash-wip Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env fish
set keyfile $HOME/.bupstash/backups.key
if not test -f $keyfile
echo Loading key from pass...
pass bupstash | tail -n+3 > $keyfile; or begin;
echo Failed to load key from pass
exit 1
end
end
set rift ssh://rift/storage/daniel-backups
bupstash init --repository $rift

18
bin/unbackupify Executable file
View file

@ -0,0 +1,18 @@
#!/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 backup filename provided"
exit 2
end
# TODO: autocomplete?
# TODO: checksum?
set fn $argv[1]
ssh $host "cat $dir/$fn$ext" |
gpg --decrypt |
zstd --ultra -T2 -22 -dc |
tar -xvf -
echo "Restored!"

0
env/nix/machines/virt.nix vendored Normal file
View file