[borg] add 'prune' setting to allow disabling pruning

This commit is contained in:
Jerome Charaoui 2018-01-14 19:06:34 -05:00
parent 60601b2f4c
commit 830a00759f
2 changed files with 26 additions and 17 deletions

View File

@ -259,25 +259,32 @@ do_borg_con() {
}
do_borg_prune() {
declare -a tmp_array
radioBox "$borg_title" "pruning (how many backups to keep" \
"yes" "regularly prune old backups" on \
"no" "keep all backups" off
[ $? = 1 ] && return;
borg_prune="$REPLY"
set -o noglob
REPLY=
formBegin "$borg_title - pruning (how many backups to keep)"
formItem "hourly" "$borg_keephourly"
formItem "daily" "$borg_keepdaily"
formItem "weekly" "$borg_keepweekly"
formItem "monthly" "$borg_keepmonthly"
formDisplay
if [ "$borg_prune" = "yes" ]; then
declare -a tmp_array
set -o noglob
REPLY=
formBegin "$borg_title - pruning (how many backups to keep)"
formItem "hourly" "$borg_keephourly"
formItem "daily" "$borg_keepdaily"
formItem "weekly" "$borg_keepweekly"
formItem "monthly" "$borg_keepmonthly"
formDisplay
[ $? = 0 ] || return
tmp_array=($REPLY)
borg_keephourly=${tmp_array[0]}
borg_keepdaily=${tmp_array[1]}
borg_keepweekly=${tmp_array[2]}
borg_keepmonthly=${tmp_array[3]}
[ $? = 0 ] || return
tmp_array=($REPLY)
borg_keephourly=${tmp_array[0]}
borg_keepdaily=${tmp_array[1]}
borg_keepweekly=${tmp_array[2]}
borg_keepmonthly=${tmp_array[3]}
set +o noglob
set +o noglob
fi
_prune_done="(DONE)"
}
@ -307,6 +314,7 @@ EOF
cat >> $next_filename <<EOF
## for more info see : borg prune -h
prune = $borg_prune
keephourly = $borg_keephourly
keepdaily = $borg_keepdaily
keepweekly = $borg_keepweekly

View File

@ -22,6 +22,7 @@ getconf testconnect yes
getconf nicelevel 0
setsection source
getconf prune yes
getconf keephourly 1
getconf keepdaily 7
getconf keepweekly 4
@ -138,7 +139,7 @@ fi
prunestr="borg prune --keep-hourly $keephourly --keep-daily $keepdaily --keep-weekly $keepweekly --keep-monthly $keepmonthly $execstr_repository"
debug "$prunestr"
if [ $test = 0 ]; then
if [ $test = 0 ] && [ "$prune" == "yes" ]; then
output="`su -c "$prunestr" 2>&1`"
if [ $? = 0 ]; then
debug $output