Repository
Munin (contrib)
Last change
2020-10-04
Graph Categories
Family
backuppc
Capabilities
Keywords
Language
Shell
License
LGPL-2.0-or-later
Authors

backuppc

Name

backuppc - monitor the age of backuppc’s most recent backup operation

Applicable Systems

Hosts with a local backuppc respository.

Configuration

[backuppc]
user backuppc
env.pcdir /var/lib/BackupPC/pc
env.full_warning 10    # warn if FULL backup older than N days
env.full_critical 20   # critical if FULL backup older than N days
env.incr_warning 1     # warn if INCR backup older than N days
env.incr_critical 3    # critical if INCR backup older than N days

Authors

Copyright (C) 2013 Steve Schnepp steve.schnepp@pwkf.org

License

GNU Library General Public License v2 or later

SPDX-License-Identifier: LGPL-2.0-or-later

Magic Markers

#%# family=backuppc
#%# capabilities=autoconf
#!/bin/sh

: <<=cut

=head1 NAME

backuppc - monitor the age of backuppc's most recent backup operation


=head1 APPLICABLE SYSTEMS

Hosts with a local backuppc respository.


=head1 CONFIGURATION

 [backuppc]
 user backuppc
 env.pcdir /var/lib/BackupPC/pc
 env.full_warning 10    # warn if FULL backup older than N days
 env.full_critical 20   # critical if FULL backup older than N days
 env.incr_warning 1     # warn if INCR backup older than N days
 env.incr_critical 3    # critical if INCR backup older than N days


=head1 AUTHORS

Copyright (C) 2013 Steve Schnepp <steve.schnepp@pwkf.org>


=head1 LICENSE

GNU Library General Public License v2 or later

SPDX-License-Identifier: LGPL-2.0-or-later


=head1 MAGIC MARKERS

 #%# family=backuppc
 #%# capabilities=autoconf

=cut


PCDIR=${pcdir:-"/var/lib/BackupPC/pc"}
HOSTS=$(cd ${PCDIR} 2>/dev/null && ls -1)

. $MUNIN_LIBDIR/plugins/plugin.sh

if [ "$1" = "autoconf" ]; then
	if [ -n "$HOSTS" ]; then
		echo "yes"
	else
		echo "no"
	fi
	exit 0
fi

if [ "$1" = "config" ]; then
	echo "multigraph backuppc_sizes"
	echo "graph_title BackupPC - Last Backup Size"
	echo "graph_args --base 1024 -l 0"
	echo "graph_vlabel Bytes"
	echo "graph_category backup"

	for h in ${HOSTS}
	do
		echo "$(clean_fieldname ${h})_full.label $(clean_fieldname ${h}) Full"
		echo "$(clean_fieldname ${h})_incr.label $(clean_fieldname ${h}) Incr"
	done

	echo "multigraph backuppc_ages"
	echo "graph_title BackupPC - Last Backup Age"
	echo "graph_args -l 0"
	echo "graph_vlabel days"
	echo "graph_category backup"

	for h in ${HOSTS}
	do
		echo "$(clean_fieldname ${h})_incr.label $(clean_fieldname ${h})"
		if [ -n "$incr_warning" ]; then
			echo "$(clean_fieldname ${h})_incr.warning $incr_warning"
		fi
		if [ -n "$incr_critical" ]; then
			echo "$(clean_fieldname ${h})_incr.critical $incr_critical"
		fi
	done

	echo "multigraph backuppc_ages_full"
	echo "graph_title BackupPC - Last Full Backup Age"
	echo "graph_args -l 0"
	echo "graph_vlabel days"
	echo "graph_category backup"

	for h in ${HOSTS}
	do
		echo "$(clean_fieldname ${h})_full.label $(clean_fieldname ${h})"
		if [ -n "$full_warning" ]; then
			echo "$(clean_fieldname ${h})_full.warning $full_warning"
		fi
		if [ -n "$full_critical" ]; then
			echo "$(clean_fieldname ${h})_full.critical $full_critical"
		fi
	done

	exit 0
fi

echo "multigraph backuppc_sizes"
for h in $HOSTS
do
	SIZE=$(awk '/full/ { size = $6 } END { print size; }' ${PCDIR}/${h}/backups)
	echo "$(clean_fieldname ${h})_full.value $SIZE"
	SIZE=$(awk '/incr/ { size = $6 } END { print size; }' ${PCDIR}/${h}/backups)
	echo "$(clean_fieldname ${h})_incr.value $SIZE"
done

echo "multigraph backuppc_ages"
for h in $HOSTS
do
	SIZE=$(awk '{ age = systime() - $3 } END { print age / 3600 / 24; }' ${PCDIR}/${h}/backups)
	echo "$(clean_fieldname ${h})_incr.value $SIZE"
done

echo "multigraph backuppc_ages_full"
for h in $HOSTS
do
	SIZE=$(awk '/full/ { age = systime() - $3 } END { print age / 3600 / 24; }' ${PCDIR}/${h}/backups)
	echo "$(clean_fieldname ${h})_full.value $SIZE"
done

<<'__END__'

Extract for the BackupPC doc, http://backuppc.sourceforge.net/faq/BackupPC.html

backups

A tab-delimited ascii table listing information about each successful backup,
one per row. The columns are:

    num
	The backup number, an integer that starts at 0 and increments for each
	successive backup. The corresponding backup is stored in the directory num
	(eg: if this field is 5, then the backup is stored in
	__TOPDIR__/pc/$host/5).

    type
	Set to "full" or "incr" for full or incremental backup.

    startTime
	Start time of the backup in unix seconds.

    endTime
	Stop time of the backup in unix seconds.

    nFiles
	Number of files backed up (as reported by smbclient, tar, rsync or
	ftp).

    size
	Total file size backed up (as reported by smbclient, tar, rsync or
	ftp).

    nFilesExist
	Number of files that were already in the pool (as determined by
	BackupPC_dump and BackupPC_link).

    sizeExist
	Total size of files that were already in the pool (as determined by
	BackupPC_dump and BackupPC_link).

    nFilesNew
	Number of files that were not in the pool (as determined by
	BackupPC_link).

    sizeNew
	Total size of files that were not in the pool (as determined by
	BackupPC_link).

    xferErrs
	Number of errors or warnings from smbclient, tar, rsync or ftp.

    xferBadFile
	Number of errors from smbclient that were bad file errors (zero
	otherwise).

    xferBadShare
	Number of errors from smbclient that were bad share errors (zero
	otherwise).

    tarErrs
	Number of errors from BackupPC_tarExtract.

    compress
	The compression level used on this backup. Zero or empty means no
	compression.

    sizeExistComp
	Total compressed size of files that were already in the pool (as
	determined by BackupPC_dump and BackupPC_link).

    sizeNewComp
	Total compressed size of files that were not in the pool (as determined
	by BackupPC_link).

    noFill
	Set if this backup has not been filled in with the most recent previous
	filled or full backup. See $Conf{IncrFill}.

    fillFromNum
	If this backup was filled (ie: noFill is 0) then this is the number of
	the backup that it was filled from

    mangle
	Set if this backup has mangled file names and attributes. Always true
	for backups in v1.4.0 and above. False for all backups prior to v1.4.0.

__END__