[GIT] refactor submodules: add all to own repo
This commit is contained in:
commit
be2b9bf3c0
27 changed files with 3311 additions and 0 deletions
67
templates/borgbackup.sh
Normal file
67
templates/borgbackup.sh
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#!/bin/sh
|
||||
# pass an arbitrary number of additional arguments to borg create by using
|
||||
# borgbackup.sh $option1 $option2 ... $optionN
|
||||
# pass -v --stats to show more information
|
||||
# pass --list --filter AME to show all fiels Added Modified or with Error
|
||||
|
||||
#export BORG_RSH='ssh -i /home/jannik/.ssh/id_rsa'
|
||||
export BORG_RSH='ssh -i /home/jannik/.ssh/id_ed25519'
|
||||
export BORG_PASSPHRASE='borgbackup.{{ borgbackup_host }}@hetznerbx'
|
||||
export BORG_REPO='ssh://u182062-sub{{ borgbackup_sub }}@u182062.your-storagebox.de:23/./borg'
|
||||
|
||||
# some helpers and error handling:
|
||||
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
|
||||
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
|
||||
|
||||
|
||||
# Backup the most important directories
|
||||
borg create \
|
||||
$@ \
|
||||
--compression lz4 \
|
||||
--exclude-caches \
|
||||
--exclude '/home/*/.cache/*' \
|
||||
--exclude '/var/run' \
|
||||
--exclude '/var/cache/*' \
|
||||
--exclude '/var/tmp/*' \
|
||||
--exclude '/var/lib/apt/*' \
|
||||
--exclude '/var/lib/dpkg/*' \
|
||||
--exclude '/var/lib/yum/*' \
|
||||
--exclude '/var/lib/docker/overlay2' \
|
||||
--exclude '/var/lib/docker/containers' \
|
||||
--exclude '/var/lib/docker/image' \
|
||||
--exclude '/var/lib/docker/tmp' \
|
||||
--exclude '/var/lib/lxcfs' \
|
||||
--exclude '/var/log/*' \
|
||||
\
|
||||
$BORG_REPO::'{{ borgbackup_host }}-{now:%Y%m%d_%H%M}' \
|
||||
/etc \
|
||||
/var \
|
||||
/root \
|
||||
/home \
|
||||
|
||||
backup_exit=$?
|
||||
|
||||
|
||||
# Prune old backups: keep 7 daily, 4 weekly and 3 monthly
|
||||
borg prune \
|
||||
--prefix '{{ borgbackup_host }}-' \
|
||||
--keep-daily 7 \
|
||||
--keep-weekly 4 \
|
||||
--keep-monthly 3
|
||||
|
||||
prune_exit=$?
|
||||
|
||||
# use highest exit code as global exit code
|
||||
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}
|
||||
Loading…
Add table
Add a link
Reference in a new issue