Skip to content
Snippets Groups Projects
Commit e28da8c3 authored by LeLutin's avatar LeLutin Committed by Guillaume Subiron
Browse files

borg: add configuration to displace the cache directory

borg will by default create its cache directory in ~/.cache/borg. This
means that during backup runs, borg will read and write quite
extensively from/to this directory.

In some situations, it is rather undesirable to have this amount of IO
activity in this location and it would make sense to tell borg to place
its cache elsewhere. This can help for example with placing the cache on
a hard drive where the added IO load will not have as big of an impact
on other running activity for the system.

This change also makes sure that the cache directory environment
variable is cleared out when the configuration option is unset. This
should avoid unpleasant surprises when this environment variable is set
to some unknown value in the context where backupninja is called, which
could lead to borg reading and writing to random places on the system.
parent f9529d1d
Branches
No related tags found
No related merge requests found
...@@ -180,3 +180,9 @@ exclude = /var/lib/mysql ...@@ -180,3 +180,9 @@ exclude = /var/lib/mysql
## ##
## Default: ## Default:
# passphrase = # passphrase =
## Path to the directory that will hold borg's cache files. By default this is
## empty, which will let borg use its default path of "~/.cache/borg".
##
## Default:
# cache_directory =
...@@ -31,6 +31,7 @@ getconf create_options ...@@ -31,6 +31,7 @@ getconf create_options
getconf prune yes getconf prune yes
getconf keep 30d getconf keep 30d
getconf prune_options getconf prune_options
getconf cache_directory
setsection dest setsection dest
getconf user getconf user
...@@ -56,6 +57,20 @@ else ...@@ -56,6 +57,20 @@ else
fi fi
execstr_archive="$archive" execstr_archive="$archive"
if [ -n "$cache_directory" ]; then
cache_parent_dir=$(dirname "$(readlink -f "$cache_directory")")
[ -d "$cache_parent_dir" ] || fatal "Cache directory parent dir '$cache_parent_dir' is absent or is not a directory."
BORG_CACHE_DIR=$cache_directory
export BORG_CACHE_DIR
else
# Cache dir not set, let's clear out the environment variable to avoid
# having this directory be pointed to a random destination.
# Also apparently if we set the variable to an empty string, borg uses the
# empty string as though it was some path we specified and backup runs
# error out, so we need to unset the variable completely.
unset BORG_CACHE_DIR
fi
# check the connection at the source and destination # check the connection at the source and destination
[ -n "$test" ] || test=0 [ -n "$test" ] || test=0
if [ "$host" != "localhost" ] && ([ "$testconnect" = "yes" ] || [ "${test}" -eq 1 ]); then if [ "$host" != "localhost" ] && ([ "$testconnect" = "yes" ] || [ "${test}" -eq 1 ]); then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment