diff options
author | Xiao Pan <xyz@flylightning.xyz> | 2025-07-11 20:37:00 +0800 |
---|---|---|
committer | Xiao Pan <xyz@flylightning.xyz> | 2025-07-11 20:37:00 +0800 |
commit | 0d68ee6d201a5ece7e707e9ce23a51db8850d6c5 (patch) | |
tree | c40b8043c911b525efdb0f0530bb65bd2adf1e7d /sh | |
parent | ffde2f2c1814a55eaa939055cf587d0956666803 (diff) |
upd edit backup code due to remove studio
Diffstat (limited to 'sh')
-rwxr-xr-x | sh/upd | 46 |
1 files changed, 23 insertions, 23 deletions
@@ -25,22 +25,21 @@ all () { } backup () { - case "$hostname" in - xyzinsp) backup_branch=master;; - *) backup_branch=${hostname#xyz};; - esac + #case "$hostname" in + # xyzinsp) backup_branch=master;; + # *) backup_branch=${hostname#xyz};; + #esac if [ "$hostname" = xyzinsp ]; then - # Pull repos and branches from studio, so one more backup on insp or duplicity will backup to ib,for one more backup for 321 backup rule - # cfgl master and pp branches already satisfy 321 rule. Here are three copies: 1. master/pp, 2. studio, 3. gitlab or alternative - # But I still copy those on insp because one more copy will not hurt. And all my other data still satisfy 3 copies without backup to gitlab, so why left out cfgl? Also it may be nice if I what to use that local dir for searching things. + # Pull repos and branches to insp, so one more backup on insp or duplicity will backup to ib + # Also sync the local dir to work on it cd "$HOME/programs/config_local_arch" || exit git branch | awk '{print ($1=="*")?$2:$1}' | while read -r branch; do git checkout "$branch" git pull - # Push any branches other than master/studio/pp to codeberg or any future alternative website for mirroring. Needed for public codes/data, considering my death may result in all copies on my computers being lost. + # Push any branches other than master/pp to codeberg or any future alternative website for mirroring. Needed for public codes/data, considering my death may result in all copies on my computers being lost. case "$branch" in - master|studio|pp) ;; + master|pp) ;; *) git push;; esac done @@ -53,37 +52,38 @@ backup () { ( umask 077 - # backup studio and other branches' cfgs, note: it backup a branch by clone/checkout to that branch first + # not needed for backup because I use insp for cfgs gitolite remote now, but I still want to sync the local dir to work on it for dir in $(sudo find /root/programs -maxdepth 1 -mindepth 1 -type d -name 'config_local_arch_secrets*'); do sudo -E git -C "$dir" pull done ) - # rsync backup from studio to insp - rsync -avPR --delete studio:/home/xyz/.config/qBittorrent :/home/xyz/.local/share/qBittorrent/BT_backup "$HOME/backup/studio" - - fi - - if [ "$hostname" = xyzinsp ] || [ "$hostname" = xyzstudio ]; then # rsync backup from ib rsync -avPR --delete xyz@ib.flylightning.xyz:/home/xyz/.config/qBittorrent :/home/xyz/.local/share/qBittorrent/BT_backup "$HOME/backup/ib" # In the future, maybe other VPS servers also need bakcup to insp and studio. - fi - if [ "$hostname" = xyzinsp ] || [ "$hostname" = xyzpp ]; then - # rsync backup to studio + # TODO: consider backup pp /home/xyz/.config/myconf/upd_rsync_files content dirs/files to insp + + # rsync backup to externel drive # --files-from make -a not imply -r, so need to specify explicitly - rsync -avPRr --delete --files-from="$XDG_CONFIG_HOME/myconf/upd_rsync_files" / "studio:/home/xyz/backup/$backup_branch" - fi + # TODO: mkdir, chown, chmod proper dirs in /run/media/xyz/bd0, see vq notes + rsync -avPRr --delete --files-from="$XDG_CONFIG_HOME/myconf/upd_rsync_files" / "/run/media/xyz/bd0/master" + sudo rsync -avPR --delete /etc/.cfgs /root/archive /root/programs "/run/media/xyz/bd0/master_root" + rsync -avP --delete "$HOME/backup/ib/" "/run/media/xyz/bd0/ib" - if [ "$hostname" = xyzinsp ] || [ "$hostname" = xyzstudio ] || [ "$hostname" = xyzpp ]; then # 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 with: insp, duplicty backuped with /etc/.cfgs, rsync backup to external drive # 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-filelist "/home/xyz/.config/myconf/upd_rsync_files" --exclude / / "sftp://xyz@ib.flylightning.xyz//home/xyz/backup/$backup_branch" + 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" + 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" fi } |