Skip to content
Snippets Groups Projects
Commit 2f1fb0dc authored by Emil Breiner's avatar Emil Breiner
Browse files

More granular configuration of removing backups of borg

Expanding the options of pruning to hourly, daily, weekly, monthly & yearly in the borg.helper. If set they are included in the pruning command in the handler.

Change-Id: I011b8abf00dc414e03e3caea67d8efa2dc1c526b
parent ab8d5a3a
No related branches found
No related tags found
1 merge request!45Draft: More granular configuration of removing backups of borg
......@@ -272,13 +272,21 @@ do_borg_prune() {
declare -a tmp_array
set -o noglob
REPLY=
formBegin "$borg_title - keep all backups made within this number of days"
formItem "keep" "$borg_keep"
formBegin "$borg_title - what backups to keep:"
formItem "hourly" "$borg_keep_hourly"
# for backwards compatibility daily is still named borg_keep
formItem "daily" "$borg_keep"
formItem "weekly" "$borg_keep_weekly"
formItem "monthly" "$borg_keep_monthly"
formItem "yearly" "$borg_keep_yearly"
formDisplay
[ $? = 0 ] || return
tmp_array=($REPLY)
borg_keep=${tmp_array[0]}
borg_keep_hourly=${tmp_array[0]}
borg_keep=${tmp_array[1]}
borg_keep_weekly=${tmp_array[2]}
borg_keep_monthly=${tmp_array[3]}
borg_keep_yearly=${tmp_array[4]}
set +o noglob
fi
......@@ -312,8 +320,13 @@ EOF
cat >> $next_filename <<EOF
## for more info see : borg prune -h
[prune]
prune = $borg_prune
keep = "${borg_keep}d"
keep_hourly = $borg_keep_hourly
keep = $borg_keep
keep_weekly = $borg_keep_weekly
keep_monthly = $borg_keep_monthly
keep_yearly = $borg_keep_yearly
[dest]
directory = $borg_directory
......@@ -381,7 +394,14 @@ borg_wizard() {
borg_compression=lz4
borg_encryption=none
borg_passphrase=
# pruning
borg_keep_hourly=
# for backwards compatibility daily is still named keep
borg_keep=30
borg_keep_weekly=
borg_keep_monthly=
borg_keep_yearly=
# Global variables whose '*' shall not be expanded
set -o noglob
......
......@@ -28,11 +28,18 @@ getconf init yes
getconf include
getconf exclude
getconf create_options
getconf prune yes
getconf keep 30d
getconf prune_options
getconf cache_directory
setsection prune
getconf prune
getconf keep_hourly
# daily is still named keep for backwards compatibility
getconf keep
getconf keep_weekly
getconf keep_monthly
getconf keep_yearly
getconf prune_options
setsection dest
getconf user
getconf host
......@@ -163,9 +170,24 @@ fi
# borg prune
if [ "$prune" == "yes" ]; then
if [ ! "$keep" == "0" ]; then
prune_options="${prune_options} --keep-within=${keep}"
# add the different pruning configurations to the cmd string if set
if [ ! -z "$keep_hourly" ]; then
prune_options="${prune_options} --keep-hourly=$keep_hourly"
fi
if [ ! -z "$keep" ]; then
prune_options="${prune_options} --keep-daily=$keep"
fi
if [ ! -z "$keep_weekly" ]; then
prune_options="${prune_options} --keep-weekly=$keep_weekly"
fi
if [ ! -z "$keep_monthly" ]; then
prune_options="${prune_options} --keep-monthly=$keep_monthly"
fi
if [ ! -z "$keep_yearly" ]; then
prune_options="${prune_options} --keep-yearly=$keep_yearly"
fi
prunestr="borg prune $prune_options $execstr_repository"
debug "$prunestr"
if [ $test = 0 ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment