dotfiles/.bin/backup-and-update-system

50 lines
1.6 KiB
Text
Raw Normal View History

2018-12-21 16:38:50 +00:00
#!/bin/sh
set -euo pipefail
set -x
2018-12-21 16:38:50 +00:00
# Push some git repos
2018-12-21 16:38:50 +00:00
pass git push
git --git-dir=$HOME/.cfg/ --work-tree=$HOME push
2018-12-21 16:38:50 +00:00
2020-12-23 08:08:37 +00:00
# Fetch a fresh copy of all locally cloned git repos
for dir in $(find /home/kunsi/git -mindepth 1 -maxdepth 1 -type d)
do
git -C "$dir" fetch || true
2020-12-23 08:08:37 +00:00
done
# Do a backup.
(
rsync -zaAP --numeric-ids --delete --relative \
--rsync-path="/usr/bin/rsync --fake-super" \
-e "ssh" --delete-excluded \
--exclude "/home/kunsi/.cache/" \
--exclude "/home/kunsi/.config/Rambox/" \
--exclude "/home/kunsi/.config/Ferdi/" \
--exclude "/home/kunsi/.local/lib/python*/site-packages/" \
--exclude "/home/kunsi/.local/share/sddm/" \
--exclude "/home/kunsi/.local/share/TelegramDesktop/tdata/user_data/cache/" \
--exclude "/home/kunsi/.mozilla/firefox/*/storage/*" \
--exclude "/home/kunsi/.npm/" \
--exclude "/home/kunsi/.nvm/" \
--exclude "/home/kunsi/.platformio/" \
--exclude "/home/kunsi/.ssh/cm-*" \
--exclude "/home/kunsi/.vdirsyncer" \
--exclude "/home/kunsi/Downloads/" \
--exclude "/home/kunsi/qemu/Windows_10.qcow2" \
--exclude "/home/kunsi/Schreibtisch/" \
--exclude "/home/kunsi/VirtualBox VMs/" \
"/home/kunsi" "kunsi-t470@home.nas":backups/
# Exit code 24 means some files have vanished during rsync.
# I don't know why, but this is very common, apparently?
exitcode=$?
if [[ $exitcode != 0 ]] && [[ $exitcode != 24 ]]
then
exit 1
fi
)
# Do updates
sudo pacman -Syu --noconfirm