From 5f33833cb5eebf2d67e191635ca218401d36407c Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Wed, 31 Aug 2016 21:31:30 +1000 Subject: [PATCH 1/3] [backup-manager] Rudimentary backup-manager plugin Signed-off-by: Olivier Mehani --- plugins/backup/backup-manager | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 plugins/backup/backup-manager diff --git a/plugins/backup/backup-manager b/plugins/backup/backup-manager new file mode 100755 index 00000000..d2eabd00 --- /dev/null +++ b/plugins/backup/backup-manager @@ -0,0 +1,39 @@ +#!/bin/sh + +# Example config: +# [backup-manager] +# user root +# env.backup_dir /path/to/your/backups/ +# env.lifetime 2 +# env.archive_pattern *.tar.bz2 +# env.backup_number 4 + +# Configuration directives, edit before first use. +BACKUP_DIR=${backup_dir:-/data/backup} +ARCHIVE_PATTERN="${archive_pattern:-*.tar.bz2}" +# How old backups should be considered as non-yound anymore in [days]. +LIFETIME=${lifetime:-2} +# Critical states will be issued when the number of fresh backups archives is below `backup_number`, +# and warnings below `backup_number*lifetime` +CRIT=${backup_number:-1} +WARN=$((${CRIT}*${LIFETIME})) + +# The situation is critical if there are no young files, the backup is down. +case $1 in + config) + cat << EOF +graph_title Fresh (<=${LIFETIME}d) backups archives in ${BACKUP_DIR} +graph_vlabel number +graph_args -l 0 +graph_category system +freshcount.label number +freshcount.critical ${CRIT}: +freshcount.warning ${WARN}: +EOF + exit 0;; +esac + +printf "freshcount.value " +find $BACKUP_DIR -name "${ARCHIVE_PATTERN}" -a -mtime -$LIFETIME | wc -l +printf "freshcount.extinfo " +du -sh $BACKUP_DIR From f751a0d865bf5b99e95eb18692cd114d7208091d Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Sat, 29 Oct 2016 11:50:50 +1100 Subject: [PATCH 2/3] [fresh-backups] Rename, cleanup, and add POD doc Signed-off-by: Olivier Mehani --- plugins/backup/backup-manager | 39 ------------------ plugins/backup/fresh-backups | 78 +++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 39 deletions(-) delete mode 100755 plugins/backup/backup-manager create mode 100755 plugins/backup/fresh-backups diff --git a/plugins/backup/backup-manager b/plugins/backup/backup-manager deleted file mode 100755 index d2eabd00..00000000 --- a/plugins/backup/backup-manager +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# Example config: -# [backup-manager] -# user root -# env.backup_dir /path/to/your/backups/ -# env.lifetime 2 -# env.archive_pattern *.tar.bz2 -# env.backup_number 4 - -# Configuration directives, edit before first use. -BACKUP_DIR=${backup_dir:-/data/backup} -ARCHIVE_PATTERN="${archive_pattern:-*.tar.bz2}" -# How old backups should be considered as non-yound anymore in [days]. -LIFETIME=${lifetime:-2} -# Critical states will be issued when the number of fresh backups archives is below `backup_number`, -# and warnings below `backup_number*lifetime` -CRIT=${backup_number:-1} -WARN=$((${CRIT}*${LIFETIME})) - -# The situation is critical if there are no young files, the backup is down. -case $1 in - config) - cat << EOF -graph_title Fresh (<=${LIFETIME}d) backups archives in ${BACKUP_DIR} -graph_vlabel number -graph_args -l 0 -graph_category system -freshcount.label number -freshcount.critical ${CRIT}: -freshcount.warning ${WARN}: -EOF - exit 0;; -esac - -printf "freshcount.value " -find $BACKUP_DIR -name "${ARCHIVE_PATTERN}" -a -mtime -$LIFETIME | wc -l -printf "freshcount.extinfo " -du -sh $BACKUP_DIR diff --git a/plugins/backup/fresh-backups b/plugins/backup/fresh-backups new file mode 100755 index 00000000..ce46ae7c --- /dev/null +++ b/plugins/backup/fresh-backups @@ -0,0 +1,78 @@ +#!/bin/sh + +: << =cut + +=head1 NAME + +fresh-backups - Plugin to monitor the freshness of backup files + +=head1 APPLICABLE SYSTEMS + +Any system with some automated backup creating or updating archive files. + +This works well with backup-manager. + +=head1 CONFIGURATION + +The following example checks all tar.bz2 files in /path/to/your/backups/, and +counts all those that are less than 2 days old, and there should be 4 separate +daily archives. + + [fresh-backups] + user root + env.backup_dir /path/to/your/backups/ + env.lifetime 2 + env.archive_pattern *.tar.bz2 + env.backup_number 4 + +This will also set the warning and critical values for this plugin to 2*4 and +4, respectively, meaning that if the number of fresh files goes below those +limits, the relevant notifications will be triggerred. + + export BM_REPOSITORY_ROOT="/path/to/your/backups" + export BM_TARBALL_FILETYPE="tar.bz2" + export BM_TARBALL_DIRECTORIES="/etc /home /srv /data" + +=head1 AUTHOR + +Olivier Mehani + +=head1 LICENSE + +GPLv2 + +=head1 MAGIC MARKERS + + #%# family=manual + +=cut + +# Configuration directives, edit before first use. +BACKUP_DIR=${backup_dir:-/data/backup} +ARCHIVE_PATTERN="${archive_pattern:-*.tar.bz2}" +# How old backups should be considered as non-yound anymore in [days]. +LIFETIME=${lifetime:-2} +# Critical states will be issued when the number of fresh backups archives is below `backup_number`, +# and warnings below `backup_number*lifetime` +CRIT=${backup_number:-1} +WARN=$((CRIT*LIFETIME)) + +# The situation is critical if there are no young files, the backup is down. +case $1 in + config) + cat << EOF +graph_title Fresh (<=${LIFETIME}d) backups archives in ${BACKUP_DIR} +graph_vlabel number +graph_args -l 0 +graph_category system +freshcount.label number +freshcount.critical ${CRIT}: +freshcount.warning ${WARN}: +EOF + exit 0;; +esac + +printf "freshcount.value " +find "${BACKUP_DIR}" -name "${ARCHIVE_PATTERN}" -a -mtime "-${LIFETIME}" | wc -l +printf "freshcount.extinfo " +du -sh "${BACKUP_DIR}" From 07fb93c2a4251e7916160a835fd6c6ffd95a2479 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Sun, 6 Nov 2016 13:18:56 +1100 Subject: [PATCH 3/3] [fresh_backup] Add missing reference to backup-manager Signed-off-by: Olivier Mehani --- plugins/backup/fresh-backups | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/backup/fresh-backups b/plugins/backup/fresh-backups index ce46ae7c..5e54cabf 100755 --- a/plugins/backup/fresh-backups +++ b/plugins/backup/fresh-backups @@ -29,10 +29,14 @@ This will also set the warning and critical values for this plugin to 2*4 and 4, respectively, meaning that if the number of fresh files goes below those limits, the relevant notifications will be triggerred. +An example configuration snippet for backup-manager [0] follows. + export BM_REPOSITORY_ROOT="/path/to/your/backups" export BM_TARBALL_FILETYPE="tar.bz2" export BM_TARBALL_DIRECTORIES="/etc /home /srv /data" +[0] https://github.com/sukria/Backup-Manager + =head1 AUTHOR Olivier Mehani