.bin/daily.sh: reorganize, use rsync instead of borgbackup
We can get away with using rsync, because we're using encrypted zfs on the other side. No need to do encryption on the source side, nor is there need to manage backup retention using borg. zfs snapshots are good enough.
This commit is contained in:
parent
e1a998c8d1
commit
b06d9d0332
1 changed files with 22 additions and 44 deletions
|
@ -1,52 +1,30 @@
|
|||
#!/bin/sh
|
||||
|
||||
export BORG_REPO=ssh://nas/storage/backups/kunsi-t470
|
||||
export BORG_PASSCOMMAND='pass show nas/backup-pass'
|
||||
set -euo pipefail
|
||||
set -x
|
||||
|
||||
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
|
||||
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
|
||||
|
||||
yay -Syu
|
||||
# Push some git repos
|
||||
pass git push
|
||||
git --git-dir=$HOME/.cfg/ --work-tree=$HOME push
|
||||
|
||||
info "Starting backup"
|
||||
# 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/.npm/" \
|
||||
--exclude "/home/kunsi/.nvm/" \
|
||||
--exclude "/home/kunsi/.platformio/" \
|
||||
--exclude "/home/kunsi/Downloads/" \
|
||||
--exclude "/home/kunsi/Schreibtisch/" \
|
||||
--exclude "/home/kunsi/VirtualBox VMs/" \
|
||||
"/home/kunsi" "kunsi-t470@nas":backups/
|
||||
|
||||
borg create \
|
||||
--stats \
|
||||
--show-rc \
|
||||
--compression lz4 \
|
||||
--exclude-caches \
|
||||
--exclude '/home/*/.cache/*' \
|
||||
--exclude '/home/*/.dbus' \
|
||||
\
|
||||
::$(date +%Y-%m-%d) \
|
||||
/home/kunsi \
|
||||
|
||||
backup_exit=$?
|
||||
|
||||
info "Pruning repository"
|
||||
|
||||
borg prune \
|
||||
--list \
|
||||
--show-rc \
|
||||
--keep-daily 7 \
|
||||
--keep-weekly 4 \
|
||||
--keep-monthly 6 \
|
||||
|
||||
prune_exit=$?
|
||||
|
||||
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
|
||||
|
||||
if [ ${global_exit} -eq 1 ];
|
||||
then
|
||||
info "Backup and/or Prune finished with a warning"
|
||||
fi
|
||||
|
||||
if [ ${global_exit} -gt 1 ];
|
||||
then
|
||||
info "Backup and/or Prune finished with an error"
|
||||
fi
|
||||
|
||||
exit ${global_exit}
|
||||
rsync -zaAP --numeric-ids --delete --relative \
|
||||
--rsync-path="/usr/bin/rsync --fake-super" \
|
||||
-e "ssh" \
|
||||
"/etc" "kunsi-t470@nas":backups/
|
||||
|
||||
# Do updates
|
||||
yay -Syu
|
||||
|
|
Loading…
Reference in a new issue