From 7cdad89918dbff8c34286a8c5f15536a89e92dd4 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 18 Feb 2021 13:26:10 -0600 Subject: [PATCH] Work on backups script --- apps/de/sway/config | 1 + bin/backupify | 21 +++++++++++++++++++++ bin/bupstash-wip | 14 ++++++++++++++ bin/unbackupify | 18 ++++++++++++++++++ env/nix/machines/virt.nix | 0 5 files changed, 54 insertions(+) create mode 100755 bin/backupify create mode 100755 bin/bupstash-wip create mode 100755 bin/unbackupify create mode 100644 env/nix/machines/virt.nix diff --git a/apps/de/sway/config b/apps/de/sway/config index a3ed737..2d6de5f 100644 --- a/apps/de/sway/config +++ b/apps/de/sway/config @@ -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 { diff --git a/bin/backupify b/bin/backupify new file mode 100755 index 0000000..6ec5004 --- /dev/null +++ b/bin/backupify @@ -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" diff --git a/bin/bupstash-wip b/bin/bupstash-wip new file mode 100755 index 0000000..e8417a6 --- /dev/null +++ b/bin/bupstash-wip @@ -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 diff --git a/bin/unbackupify b/bin/unbackupify new file mode 100755 index 0000000..92a8e6e --- /dev/null +++ b/bin/unbackupify @@ -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!" diff --git a/env/nix/machines/virt.nix b/env/nix/machines/virt.nix new file mode 100644 index 0000000..e69de29