From 03eb2e047507e1276bd7beb6ea3365af34a52d24 Mon Sep 17 00:00:00 2001 From: Xiao Pan Date: Sun, 28 Sep 2025 21:27:44 +0800 Subject: upd back consider no external HDD Because I forget to bring my external HDD with me. So I choose to duplicity backup things to ca and rsync backup ib things to pp instead for now. Note I also duplicity backup insp /root/programs now because cfgs repos in /root/programs now need to be duplicity backuped to ca and ib to satisified 321 backup rule because they are not backuped to external HDD now. --- sh/upd | 53 +++++++++-------------------------------------------- 1 file changed, 9 insertions(+), 44 deletions(-) diff --git a/sh/upd b/sh/upd index b54be61..c7751e8 100755 --- a/sh/upd +++ b/sh/upd @@ -77,62 +77,27 @@ backup () { # --files-from make -a not imply -r, so need to specify explicitly rsync -avPRr --delete --files-from="$XDG_CONFIG_HOME/myconf/upd_rsync_files_pp" pp:/ "$HOME/backup/pp" - # rsync backup to externel drive - while ! [ -d /run/media/xyz/bd0 ]; do - alarm 0 'Plug in external HDD' - echo 'Plug in external HDD' - sleep 10 - done - # --files-from make -a not imply -r, so need to specify explicitly - # TODO: first time mkdir, chown, chmod proper dirs in /run/media/xyz/bd0, see vq notes - # backup insp - rsync -avPRr --delete --files-from="$XDG_CONFIG_HOME/myconf/upd_rsync_files" / "/run/media/xyz/bd0/master" - # need to backup VPS cfgs repos (ca, ib, ba, etc.) in /root/programs to external HDD to satisfy 321 backup rule - # need to backup insp cfgs repo to external HDD to satisfy 321 backup rule - sudo rsync -avPR --delete /etc/.cfgs /root/archive /root/programs "/run/media/xyz/bd0/master_root" - # backup ib - rsync -avP --delete "$HOME/backup/ib/" "/run/media/xyz/bd0/ib" - # backup pp - rsync -avP --delete "$HOME/backup/pp/" "/run/media/xyz/bd0/pp" - - # bd0 is the label name of the unlocked ext4 fs, maybe was configured - # with sth. like `sudo e2label /dev/mapper/luks-... bd0`. ebd0 is the - # label name of the locked crypto_LUKS fs, maybe was configured with - # `sudo cryptsetup config /dev/sdx --label ebd0`. - # - # Another way to represent disk is using uuid. ebd0 locked crypto_LUKS - # fs uuid is cf91dfaa-35dc-4ce4-b333-df15966f34a2, so I can use - # /dev/disk/by-uuid/cf91dfaa-35dc-4ce4-b333-df15966f34a2 to represent - # it. bd0 unlocked ext4 fs uuid is - # 93670fb4-af1d-43aa-a8cc-b7ac5c05e766, so I can use - # /dev/disk/by-uuid/93670fb4-af1d-43aa-a8cc-b7ac5c05e766 for it, I can - # also use /dev/mapper/luks-cf91dfaa-35dc-4ce4-b333-df15966f34a2 for - # bd0, note here cf91dfaa-35dc-4ce4-b333-df15966f34a2 is the ebd0 - # 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 ebd0 locked crypto_LUKS fs, but `sudo - # cryptsetup close` need bd0 unlocked ext4 fs. - umount /run/media/xyz/bd0 - udisksctl lock -b /dev/disk/by-label/ebd0 - udisksctl power-off -b /dev/disk/by-label/ebd0 - alarm 0 'Unplug external HDD' + # backup ib to pp, not much storage needed and I don't want to use duplicity to backup to ca yet again + rsync -avP --delete "$HOME/backup/ib" pp:backup # duplicity backup to ib - # note no need to duplicity backup /root/programs to ib for now, because /root/programs now only has cfgs repos which already satisfied 321 backup rule, e.g, insp cfgs is backed up with: insp, duplicty backuped with /etc/.cfgs, rsync backup to external HDD; ib cfgs is backed up with: ib, insp gitolite, insp rsync backup /root/programs to external HDD # https://wiki.archlinux.org/title/Duplicity # Need // for absolute path, see manpage URL FORMAT section. If not use //, will store to /home/xyz/home/xyz/... # --files-from has a bug, this bug makes source url that is / not working while /home works, more see vq notes # --use-agent not working when ssh to pp and insp, works on insp, not sure why # --use-agent maybe timeout on gpg key and failed when do full backup, maybe due to key stored in gpg agent timeout, so I'm not using --use-agent on insp now - sudo duplicity --ssh-askpass --encrypt-key 9790577D2BE328D46838117ED3F54FE03F3C68D6 --sign-key 05899270DF25BB1EEDF57BE824F769E5D08C9E9A --full-if-older-than 2Y --include /etc/.cfgs --include /root/archive --include-filelist "/home/xyz/.config/myconf/upd_rsync_files" --exclude / / "sftp://xyz@ib.flylightning.xyz//home/xyz/backup/master" + sudo duplicity --ssh-askpass --encrypt-key 9790577D2BE328D46838117ED3F54FE03F3C68D6 --sign-key 05899270DF25BB1EEDF57BE824F769E5D08C9E9A --full-if-older-than 2Y --include /etc/.cfgs --include /root/archive --include /root/programs --include-filelist "/home/xyz/.config/myconf/upd_rsync_files" --exclude / / "sftp://xyz@ib.flylightning.xyz//home/xyz/backup/master" + + # duplicity backup to ca + sudo duplicity --ssh-askpass --encrypt-key 9790577D2BE328D46838117ED3F54FE03F3C68D6 --sign-key 05899270DF25BB1EEDF57BE824F769E5D08C9E9A --full-if-older-than 2Y --include /etc/.cfgs --include /root/archive --include /root/programs --include-filelist "/home/xyz/.config/myconf/upd_rsync_files" --exclude / / "sftp://xyz@ca.flylightning.xyz//home/xyz/backup/master" fi if [ "$hostname" = xyzpp ]; then # duplicity backup to ib sudo duplicity --ssh-askpass --encrypt-key 9790577D2BE328D46838117ED3F54FE03F3C68D6 --sign-key 05899270DF25BB1EEDF57BE824F769E5D08C9E9A --full-if-older-than 2Y --include /etc/.cfgs --include-filelist "/home/xyz/.config/myconf/upd_rsync_files" --exclude / / "sftp://xyz@ib.flylightning.xyz//home/xyz/backup/pp" + + # duplicity backup to ca + sudo duplicity --ssh-askpass --encrypt-key 9790577D2BE328D46838117ED3F54FE03F3C68D6 --sign-key 05899270DF25BB1EEDF57BE824F769E5D08C9E9A --full-if-older-than 2Y --include /etc/.cfgs --include-filelist "/home/xyz/.config/myconf/upd_rsync_files" --exclude / / "sftp://xyz@ca.flylightning.xyz//home/xyz/backup/pp" fi } -- cgit v1.2.3-70-g09d2