summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiao Pan <xyz@flylightning.xyz>2025-10-03 21:30:51 +0800
committerXiao Pan <xyz@flylightning.xyz>2025-10-03 21:30:51 +0800
commit78bdc577e711a9c9aaee3e1757291b9984eb3b95 (patch)
tree3d3bf8a98f89436c8770ee88fe3aec1ef6438c48
parente7be18d88749047867f31eca0acaadb237e7ddcd (diff)
upd monthly backup diaster recovery usb flash drive
-rwxr-xr-xsh/upd48
1 files changed, 45 insertions, 3 deletions
diff --git a/sh/upd b/sh/upd
index be762cf..44f750f 100755
--- a/sh/upd
+++ b/sh/upd
@@ -288,6 +288,48 @@ monthly_misc () {
if [ "$hostname" = xyzinsp ]; then
sudo scp xyz@ba.flylightning.xyz:/etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist
+ # Monthly backup gpg key, ssh key, ~/.password-store, and notes for
+ # backup diaster recovery in case both my insp laptop and pp phone are
+ # lost. I prefer monthly backup those instead of backup those more
+ # frequently, because plug in and unplug drives more frequently is
+ # tedious and things backed up in bd2 does not need to be very recent.
+ while ! [ -d /run/media/xyz/bd2 ]; do
+ alarm 0 'Plug in bd2 usb flash drive'
+ echo 'Plug in bd2 usb flash drive'
+ sleep 10
+ done
+ git -C /run/media/xyz/bd2/backup/notes pull
+ git -C /run/media/xyz/bd2/backup/.password-store pull
+ # consider password change for the keys and I forget to backup the keys
+ # encrypted with new password
+ #
+ # these two files are not directory so I think --delete is unnecessary
+ rsync -avP "$XDG_DOCUMENTS_DIR/paperwork/sec_pgp_key.asc" "$HOME/.ssh/id_rsa" /run/media/xyz/bd2/backup
+ # bd2 is the label name of the unlocked ext4 fs, it was configured with
+ # sth. like `sudo e2label /dev/mapper/luks-... bd2`. ebd2 is the label
+ # name of the locked crypto_LUKS fs, it was configured with `sudo
+ # cryptsetup config /dev/sdx --label ebd2`.
+ #
+ # Another way to represent disk is using uuid. ebd2 locked crypto_LUKS
+ # fs uuid is 0c2fceb2-9743-4872-99f7-8d87d53c9270, so I can use
+ # /dev/disk/by-uuid/0c2fceb2-9743-4872-99f7-8d87d53c9270 to represent
+ # it. bd2 unlocked ext4 fs uuid is
+ # f7da70df-94a1-478d-98a2-86af8be54c56, so I can use
+ # /dev/disk/by-uuid/f7da70df-94a1-478d-98a2-86af8be54c56 for it, I can
+ # also use /dev/mapper/luks-0c2fceb2-9743-4872-99f7-8d87d53c9270 for
+ # bd2, note here 0c2fceb2-9743-4872-99f7-8d87d53c9270 is the ebd2
+ # locked crypto_LUKS fs uuid. However, udisksctl does not recognize
+ # /dev/mapper/luks-..., but recognize /dev/disk/...; cryptosetup close
+ # and umount recognize both. More ways see dirs in /dev/disk, and see
+ # output of press tab after `udiskiectl info -b`.
+ #
+ # Note `udisksctl lock` need ebd2 locked crypto_LUKS fs, but `sudo
+ # cryptsetup close` need bd2 unlocked ext4 fs.
+ umount /run/media/xyz/bd2
+ udisksctl lock -b /dev/disk/by-label/ebd2
+ udisksctl power-off -b /dev/disk/by-label/ebd2
+ alarm 0 'Unplug bd2 usb flash drive'
+
# https://github.com/qbittorrent/qBittorrent/wiki#webui-api
curl -sS -X POST 'ibwg:57151/api/v2/search/updatePlugins' &
# in the past, I have both stwg and ibwg, now only one
@@ -299,8 +341,8 @@ monthly_misc () {
wait
while ! [ -d /run/media/xyz/Ventoy ]; do
- alarm 0 'Plug in usb flash drive'
- echo 'Plug in usb flash drive'
+ alarm 0 'Plug in ventoy usb flash drive'
+ echo 'Plug in ventoy usb flash drive'
sleep 10
done
#[ -d /run/media/xyz/Ventoy ] || die "No usb flash drive"
@@ -331,7 +373,7 @@ monthly_misc () {
umount /run/media/xyz/Ventoy /run/media/xyz/FAT32DIR
udisksctl power-off -b /dev/disk/by-label/Ventoy
- alarm 0 'Unplug usb flash drive'
+ alarm 0 'Unplug ventoy usb flash drive'
fi
}