Merge pull request #14 from fbartels/master

smaller cosmetics and tagging of main/local backup job
This commit is contained in:
Alexander Rust 2018-01-23 16:55:23 +01:00 committed by GitHub
commit c9b850d7dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 16 deletions

View file

@ -1,9 +1,6 @@
#! /bin/bash
set -uo pipefail
#backup li run
#backup li
display_usage() {
echo "Usage: $0 <repo> (local|monitor <host> <warning> <critical>|restic arguments)" >&2
}
@ -13,7 +10,6 @@ if [ "$#" -lt 2 ]; then
exit 1
fi
TARGET=$1
ACTION=$2
RESTIC=$(which restic)
@ -35,8 +31,6 @@ check_config() {
echo "Restic binary not found"
exit 1
fi
}
handle_params () {
@ -60,11 +54,14 @@ do_local_backup () {
. /etc/backup/local.config
# define an empty default if BACKUP_ARGS is not set
BACKUP_ARGS=${BACKUP_ARGS:-""}
if [[ -x /etc/backup/local.pre ]]; then
/etc/backup/local.pre $TARGET
fi
$RESTIC --exclude-file /etc/backup/local.exclude backup --hostname $BACKUP_HOSTNAME $BACKUP_DIR
$RESTIC --exclude-file /etc/backup/local.exclude backup --hostname $BACKUP_HOSTNAME $BACKUP_ARGS $BACKUP_DIR
if [[ -x /etc/backup/local.post ]]; then
/etc/backup/local.post $TARGET
@ -109,6 +106,7 @@ do_monitor () {
BACKUP_TST=$(date -d "$DATE $TIME" +"%s" )
;;
esac
NOW_TST=$(date +%s)
DIFF_S=`expr $NOW_TST - $BACKUP_TST`
@ -133,9 +131,5 @@ do_monitor () {
return $RET
}
check_config $@
handle_params $@

View file

@ -1,3 +1,4 @@
BACKUP_HOSTNAME="backuphost.example.org"
BACKUP_DIR="/"
BACKUP_ARGS="--tag filesystem"
# HEALTHCHECK_URL="<URL from https://healthchecks.io/checks/ to notify>"

1
etc/backup/local.post Executable file
View file

@ -0,0 +1 @@
# run commands after the backup (script must be executable)

1
etc/backup/local.pre Executable file
View file

@ -0,0 +1 @@
# run commands before the backup (script must be executable)