Add support for bandwith limitation
parent
ffdf749e8b
commit
8bb2a0e178
|
|
@ -87,6 +87,19 @@ borg_exec () {
|
||||||
${BORG} "$@"
|
${BORG} "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
limit_bw () {
|
||||||
|
if ! [[ -x $(command -v pv) ]]; then
|
||||||
|
>&2 echo "WARNING: BWLIMIT is enabled, but the utility 'pv' is not available. Continuing without bandwith limitation."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PV_WRAPPER=$(mktemp)
|
||||||
|
chmod +x ${PV_WRAPPER}
|
||||||
|
echo -e '#!/bin/bash\npv -q -L ${BWLIMIT} | "$@"' > ${PV_WRAPPER}
|
||||||
|
export BWLIMIT
|
||||||
|
export BORG_RSH="${PV_WRAPPER} ssh"
|
||||||
|
}
|
||||||
|
|
||||||
pre_backup_cmd () {
|
pre_backup_cmd () {
|
||||||
[[ -n ${PRE_BACKUP_CMD} ]] || return 0
|
[[ -n ${PRE_BACKUP_CMD} ]] || return 0
|
||||||
echo "Running pre backup command: ${PRE_BACKUP_CMD[@]}"
|
echo "Running pre backup command: ${PRE_BACKUP_CMD[@]}"
|
||||||
|
|
@ -121,6 +134,7 @@ lock_failed () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_clean () {
|
exit_clean () {
|
||||||
|
[[ -n ${PV_WRAPPER} ]] && rm -f ${PV_WRAPPER}
|
||||||
trap - ERR INT TERM
|
trap - ERR INT TERM
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
@ -162,6 +176,10 @@ export BORG_PASSPHRASE
|
||||||
trap 'error_handler ${LINENO} $?' ERR INT TERM
|
trap 'error_handler ${LINENO} $?' ERR INT TERM
|
||||||
set -o errtrace -o pipefail
|
set -o errtrace -o pipefail
|
||||||
|
|
||||||
|
if [[ ${BWLIMIT} -gt 0 ]]; then
|
||||||
|
limit_bw
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ${MODE} == "init" ]]; then
|
if [[ ${MODE} == "init" ]]; then
|
||||||
borg_init
|
borg_init
|
||||||
elif [[ ${MODE} == "backup" ]]; then
|
elif [[ ${MODE} == "backup" ]]; then
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@ KEEP_WEEKLY=0
|
||||||
KEEP_MONTHLY=24
|
KEEP_MONTHLY=24
|
||||||
KEEP_YEARLY=5
|
KEEP_YEARLY=5
|
||||||
|
|
||||||
|
# Limit bandwith used when backing up to SSH repositories. Requires the utility `pv`.
|
||||||
|
# The unit is bytes per second. 0 means no limit.
|
||||||
|
#BWLIMIT=0
|
||||||
|
|
||||||
# Change this if you need to have multiple borgwrapper instances running
|
# Change this if you need to have multiple borgwrapper instances running
|
||||||
# using different configs.
|
# using different configs.
|
||||||
#LOCKFILE="/var/lock/borgwrapper.lock"
|
#LOCKFILE="/var/lock/borgwrapper.lock"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue