diff options
Diffstat (limited to 'backup.in')
-rw-r--r-- | backup.in | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/backup.in b/backup.in new file mode 100644 index 0000000..f14850f --- /dev/null +++ b/backup.in @@ -0,0 +1,110 @@ +#! /bin/bash +# This script creates a backup of this system. For usage instructions, +# run `backup --help'. For a detailed description of the backup and +# restore procedures, see /export/backup/snapshot/README. + +libdir=@LIBDIR@/backup +set -e +. $libdir/common.sh +set +e +ts=`date +%Y%m%d`; +week=`date +%U` + +# Add version-specific tar options +tar_version_options() { + set -- $(tar --version | awk 'NR==1 {gsub(/\./, " ",$NF); print $NF}') + if [ $# -ge 2 ]; then + v=$((1 * 1000 + $2)) + if [ $v -gt 1025 ]; then + taroptions="$taroptions --level=$level" + fi + fi +} + +load_config +taroptions="-Hpax $backup_tar_options $backup_rsh_command" + +########################################################### +# Global variables +########################################################### + +# Set it to "-v" to make script verbose +if [ -n "$backup_verbose" ]; then + verbose=-v +else + verbose= +fi +# Set it to "echo" to initiate dry-run mode. +dry_run= + +# Number of tar errors detected during the run +tarerror=0 + +level=0 +round=0 + +########################################################### +# Utility functions +########################################################### + +help() { + cat <<EOF +usage: $0 [OPTIONS] +makes incremental backup of that system + +OPTIONS: + + -v, --verbose increase verbosity + -l, --logfile FILE log to FILE (default $backup_logfile) + -n, --dry-run do nothing, print what would have been done + -N, --no-logfile log to stderr + -L, --level N create incremental dump level N + -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 +EOF + 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;; + -N|--no-logfile) backup_logfile=;; + -h|--help) help;; + -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 + +tar_version_options + +if [ -n "$backup_logfile" ]; then + exec >>$backup_logfile + exec 2>&1 +fi +logit "started" + +$prologue_hook + +for item in $backup_items +do + eval type=\$${item}_type + ${type}_backup $item +done + +$epilogue_hook + +logit "finished" + +# finis coronat opus + |