Skip to content
Snippets Groups Projects
Commit 1d7e00fa authored by Guillaume Subiron's avatar Guillaume Subiron
Browse files

borg: allow to export borg list and borg info for monitoring

parent 0bce7106
No related branches found
No related tags found
1 merge request!69Multiple improvements in borg handler
......@@ -46,6 +46,22 @@
## Default:
# bwlimit = 0
## export "borg info last_archive" to a given file
## this is usefull for monitoring without using borg
##
## Example:
# borginfo = /var/backups/borginfo.json
## Default:
# borginfo =
## export "borg list repository" to a given file
## this is usefull for monitoring without using borg
##
## Example
# borglist = /var/backups/borglist.json
## Default:
# borglist =
######################################################
## source section
## (where the files to be backed up are coming from)
......
......@@ -31,6 +31,9 @@ getconf nicelevel 0
getconf ionicelevel
getconf bwlimit
getconf borginfo
getconf borglist
setsection source
getconf init yes
getconf include
......@@ -250,8 +253,48 @@ if [ "$prune" == "yes" ]; then
warning "$output"
warning "Removing old backups finished with warnings."
else
error $output
fatal "Failed removing old backups."
info "$output"
warning "Failed removing old backups. Borg returned exit code ${ret}."
fi
fi
fi
### WRITE STATS FILES ###
if [ -n "$borginfo" ]; then
mkdir -p "$(dirname "$borginfo")"
infostr="borg info $execstr_repository --last 1 --json > $borginfo"
debug "$infostr"
if [ "$test" = 0 ]; then
output=$(su -c "$infostr" 2>&1)
ret=$?
if [ $ret = 0 ]; then
debug "$output"
info "Successfully writing borg info to $borginfo"
else
info "$output"
error "Failed to write borg info to $borginfo"
fi
fi
fi
if [ -n "$borglist" ]; then
mkdir -p "$(dirname "$borglist")"
infostr="borg list $execstr_repository --json > $borglist"
debug "$infostr"
if [ "$test" = 0 ]; then
output=$(su -c "$infostr" 2>&1)
ret=$?
if [ $ret = 0 ]; then
debug "$output"
info "Successfully writing borg list to $borglist"
else
info "$output"
error "Failed to write borg list to $borglist"
fi
fi
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment