can use alternate config file via BORG_CONF env var
write statusfile for zabbix monitoring
This commit is contained in:
parent
a51e957105
commit
2e78fb23f2
@ -2,4 +2,5 @@ REPOSITORY={{borg_account}}@{{ borg_server }}:{{ borg_remote_dir }}/{{ ansible_h
|
||||
export BORG_PASSPHRASE={{ borg_passphrase }}
|
||||
borg=/usr/bin/borg
|
||||
rotate={{ borg_rotate }}
|
||||
src="{{ borg_dirs }}"
|
||||
src="{{ borg_dirs }}"
|
||||
statusfile=/run/zabbix/borg.status
|
||||
21
borg.sh
Normal file → Executable file
21
borg.sh
Normal file → Executable file
@ -1,9 +1,17 @@
|
||||
#! /bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# wrapper around borgbackup
|
||||
# need a borg.conf file - see example file
|
||||
# alternate conf file can be passed through BORG_CONF env variable
|
||||
# need passwordless ssh access if using remote repo
|
||||
conf=$(dirname $0)/borg.conf
|
||||
|
||||
if [ -v BORG_CONF ] ; then
|
||||
conf=$BORG_CONF
|
||||
else
|
||||
conf=$(dirname $0)/borg.conf
|
||||
fi
|
||||
|
||||
if [ ! -f $conf ] ; then
|
||||
echo config file not found
|
||||
exit 5
|
||||
@ -15,11 +23,11 @@ TODAY=$(date "+%Y%m%d")
|
||||
|
||||
case $1 in
|
||||
("list")
|
||||
if [ ! -z $2 ] ; then
|
||||
${borg} list $options ${REPOSITORY}::${2}
|
||||
if [ -v 2 ] ; then
|
||||
${borg} list ${REPOSITORY}::${2}
|
||||
ret=$?
|
||||
else
|
||||
${borg} list $options $REPOSITORY
|
||||
${borg} list $REPOSITORY
|
||||
ret=$?
|
||||
fi
|
||||
;;
|
||||
@ -46,10 +54,11 @@ case $1 in
|
||||
ret=$?
|
||||
;;
|
||||
(*)
|
||||
${borg} create $options --compression lzma,5 $REPOSITORY::$(hostname)_${TODAY} ${src}
|
||||
${borg} create --compression lzma,5 $REPOSITORY::$(hostname)_${TODAY} ${src}
|
||||
ret=$?
|
||||
test -d $(dirname $statusfile) && echo $ret > $statusfile
|
||||
if [ $ret -eq 0 ] ; then
|
||||
${borg} prune $options $REPOSITORY --prefix $(hostname)_ --keep-daily=${rotate}
|
||||
${borg} prune $REPOSITORY --prefix $(hostname)_ --keep-daily=${rotate}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user