2018-12-21 16:38:50 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-10-26 07:39:32 +00:00
|
|
|
export BORG_REPO=ssh://nas/storage/backups/kunsi-t470
|
2018-12-21 16:38:50 +00:00
|
|
|
export BORG_PASSCOMMAND='pass show nas/backup-pass'
|
|
|
|
|
|
|
|
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
|
|
|
|
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
|
|
|
|
|
|
|
|
yay -Syu
|
|
|
|
pass git push
|
2019-09-24 14:13:41 +00:00
|
|
|
git --git-dir=$HOME/.cfg/ --work-tree=$HOME push
|
2018-12-21 16:38:50 +00:00
|
|
|
|
|
|
|
info "Starting backup"
|
|
|
|
|
|
|
|
borg create \
|
|
|
|
--stats \
|
|
|
|
--show-rc \
|
|
|
|
--compression lz4 \
|
|
|
|
--exclude-caches \
|
|
|
|
--exclude '/home/*/.cache/*' \
|
|
|
|
--exclude '/home/*/.dbus' \
|
|
|
|
\
|
2019-10-26 07:39:32 +00:00
|
|
|
::$(date +%Y-%m-%d) \
|
2018-12-21 16:38:50 +00:00
|
|
|
/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}
|
|
|
|
|