aboutsummaryrefslogtreecommitdiff
path: root/backup.in
diff options
context:
space:
mode:
Diffstat (limited to 'backup.in')
-rw-r--r--backup.in100
1 files changed, 50 insertions, 50 deletions
diff --git a/backup.in b/backup.in
index ca479b1..477b839 100644
--- a/backup.in
+++ b/backup.in
@@ -1,9 +1,9 @@
#! /bin/sh
# This file is part of BEAM
-# Copyright (C) 2012 Sergey Poznyakoff
+# Copyright (C) 2012-2014 Sergey Poznyakoff
#
# BEAM is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
@@ -20,28 +20,28 @@ set -e
. $libdir/common.sh
set +e
ts=`date +%Y%m%d`;
week=`date +%U`
if [ "$1" = "--wtf" ]; then
- wtf $(basename $0) create a backup
- exit 0
+ wtf $(basename $0) create a backup
+ exit 0
fi
load_config
taroptions="-c -Hpax $backup_tar_options $backup_rsh_command"
###########################################################
# Global variables
###########################################################
# Set it to "-v" to make script verbose
if [ -n "$backup_verbose" ]; then
- verbose=-v
+ verbose=-v
else
- verbose=
+ verbose=
fi
# Set it to "echo" to initiate dry-run mode.
unset dry_run
# Number of tar errors detected during the run
tarerror=0
@@ -51,13 +51,13 @@ round=0
###########################################################
# Utility functions
###########################################################
help() {
- cat <<EOF
+ cat <<EOF
usage: $0 [OPTIONS]
makes incremental backup of that system
OPTIONS:
-v, --verbose increase verbosity
@@ -68,77 +68,77 @@ OPTIONS:
-R, --round N mark archives with incremental round N
--week N force using week number N instead of the current one
-h, --help produce this help list
Report bugs to <@PACKAGE_BUGREPORT@>
EOF
- exit 0
+ exit 0
}
###########################################################
# Main
###########################################################
while [ $# -ne 0 ]
do
- case $1 in
- -v|--verbose) verbose="$verbose -v";;
- -l|--logfile) shift; backup_logfile=$1;;
- -n|--dry-run) dry_run=echo; backup_logfile=;;
- -N|--no-logfile) backup_logfile=;;
- -h|--help) help;;
- -V|--version) print_version;;
- -L|--level) shift; level=$1;;
- -R|--round) shift; round=$1;;
- --week) shift; week=$1;;
- *) echo >&2 "$0: unrecognized option $1"; exit 1;;
- esac
- shift
+ case $1 in
+ -v|--verbose) verbose="$verbose -v";;
+ -l|--logfile) shift; backup_logfile=$1;;
+ -n|--dry-run) dry_run=echo; backup_logfile=;;
+ -N|--no-logfile) backup_logfile=;;
+ -h|--help) help;;
+ -V|--version) print_version;;
+ -L|--level) shift; level=$1;;
+ -R|--round) shift; round=$1;;
+ --week) shift; week=$1;;
+ *) echo >&2 "$0: unrecognized option $1"; exit 1;;
+ esac
+ shift
done
backup() {
- logit "started"
-
- runhook prologue_hook
- trap "runhook epilogue_hook" EXIT INT QUIT TERM
-
- if test -n "$backup_retain_interval" &&
- test $backup_retain_interval -gt 0; then
- @LIBEXECDIR@/beam-cleaner --retain $backup_retain_interval $verbose \
+ logit "started"
+
+ runhook prologue_hook
+ trap "runhook epilogue_hook" EXIT INT QUIT TERM
+
+ if test -n "$backup_retain_interval" &&
+ test $backup_retain_interval -gt 0; then
+ @LIBEXECDIR@/beam-cleaner --retain $backup_retain_interval $verbose \
${dry_run+--dry-run} --suffix $backup_suffix $backup_archive_dir
- @LIBEXECDIR@/beam-cleaner --retain $backup_retain_interval $verbose \
+ @LIBEXECDIR@/beam-cleaner --retain $backup_retain_interval $verbose \
${dry_run+--dry-run} --suffix .db $backup_snapshot_dir
- fi
-
- for item in $backup_items
- do
- eval type=\$${item}_type
- ${type}_backup $item
- done
-
- trap - EXIT INT QUIT TERM
- runhook epilogue_hook
-
- logit "finished"
+ fi
+
+ for item in $backup_items
+ do
+ eval type=\$${item}_type
+ ${type}_backup $item
+ done
+
+ trap - EXIT INT QUIT TERM
+ runhook epilogue_hook
+
+ logit "finished"
}
umask ${backup_umask:-077}
prologue_hook="beam_lock $prologue_hook"
if [ -n "$backup_logfile" ]; then
- runhook openlog_hook
- exec >>$backup_logfile
- exec 2>&1
+ runhook openlog_hook
+ exec >>$backup_logfile
+ exec 2>&1
fi
if [ -z "$backup_notify_email" ]; then
- backup
+ backup
else
- report=$backup_snapshot_dir/report.$$
- touch $report
- backup 2>&1 | tee $report
- mail_report $report
- rm $report
+ report=$backup_snapshot_dir/report.$$
+ touch $report
+ backup 2>&1 | tee $report
+ mail_report $report
+ rm $report
fi
# finis coronat opus

Return to:

Send suggestions and report system problems to the System administrator.