diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2024-06-24 18:17:56 -0700 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2024-06-24 18:17:56 -0700 |
commit | 989495cf4c96b9caab39fff71b57d833fab26a8f (patch) | |
tree | 22e1323ab4759c8ec40c7e7f0c31f7a26f4408a3 /sh | |
parent | 9954a1eca1badfd340744fbc46cf4d61e5e0542d (diff) |
refactor: upd less code to add for new VPS
Diffstat (limited to 'sh')
-rwxr-xr-x | sh/upd | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -27,9 +27,11 @@ backup () { git branch | awk '{print ($1=="*")?$2:$1}' | while read -r branch; do git checkout "$branch" git pull - # Push ca and ia branch 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 ca, ia, and other new vps branches (which means 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. case "$branch" in - ia|ca) git push;; + # here, : seems no need + master|studio|pp) :;; + *) git push;; esac done # git checkout will change mtime, need to change back so rsync won't think it needs to backup these files @@ -41,12 +43,10 @@ backup () { ( umask 077 - # backup studio cfgs, note: it backup a branch by clone/checkout to that branch first - sudo -E git -C /root/programs/config_local_arch_secrets pull - # backup ia cfgs - sudo -E git -C /root/programs/config_local_arch_secrets_ia pull - # backup ca cfgs - sudo -E git -C /root/programs/config_local_arch_secrets_ca pull + # backup studio and other branches' cfgs, note: it backup a branch by clone/checkout to that branch first + 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 @@ -57,15 +57,16 @@ backup () { if [ "$hostname" = xyzinsp ] || [ "$hostname" = xyzstudio ]; then # rsync backup from ia rsync -avPR --delete ia:/home/xyz/.config/qBittorrent :/home/xyz/.local/share/qBittorrent/BT_backup "$HOME/backup/ia" + # In the future, maybe other VPS servers also need bakcup to insp and studio. Now, only ia needs fi - if [ "$hostname" != xyzstudio ] && [ "$hostname" != xyzia ] && [ "$hostname" != xyzca ]; then + if [ "$hostname" = xyzinsp ] || [ "$hostname" = xyzpp ]; then # rsync backup to studio # --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 - if [ "$hostname" != xyzia ] && [ "$hostname" != xyzca ]; then + if [ "$hostname" = xyzinsp ] || [ "$hostname" = xyzstudio ] || [ "$hostname" = xyzpp ]; then # duplicity backup to ia # 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/... @@ -112,7 +113,7 @@ clean () { fast () { pac misc - if [ "$hostname" != xyzia ] && [ "$hostname" != xyzca ]; then + if [ "$hostname" = xyzinsp ] || [ "$hostname" = xyzstudio ] || [ "$hostname" = xyzpp ]; then backup fi } |