Initial commit

master
Bryan 2020-06-24 10:09:07 -06:00
commit c8def429cd
1 changed files with 55 additions and 0 deletions

55
backup.sh Normal file
View File

@ -0,0 +1,55 @@
#! /bin/bash
REPO=""
PASSPHRASE=""
export BORG_REPO=$REPO
export BORG_PASSPHRASE=$PASSPHRASE
info(){ printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
info "Starting backup"
borg create \
--verbose \
--filter AME \
--list \
--stats \
--show-rc \
--compression lz4 \
--exclude-caches \
\
####---put exclude directories here
::'{hostname}-{now}'\
#####---put directories to be backed up here
backup_exit=$?
info "Pruning repository"
borg prune \
--list \
--prefix '{hostname}-' \
--show-rc \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 6 \
prune_exit=$?
# use highest exit code as global exit code
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
if [ ${global_exit} -eq 0 ]; then
info "Backup and Prune finished successfully"
elif [ ${global_exit} -eq 1 ]; then
info "Backup and/or Prune finished with warnings"
else
info "Backup and/or Prune finished with errors"
fi
exit ${global_exit}