#! /bin/bash
# This file is part of BEAM
# Copyright (C) 2012 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.
#
# BEAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BEAM. If not, see .
libdir=@LIBDIR@/beam
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
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
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
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
done
if [ -n "$backup_logfile" ]; then
exec >>$backup_logfile
exec 2>&1
fi
logit "started"
if test -n "$backup_retain_interval" && test $backup_retain_interval -gt 0; then
@LIBEXECDIR@/beam-cleaner --retain $backup_retain_interval $verbose \
--suffix .tar.bz2 $backup_archive_dir
@LIBEXECDIR@/beam-cleaner --retain $backup_retain_interval $verbose \
--suffix .db $backup_snapshot_dir
fi
runhook prologue_hook
trap "runhook epilogue_hook" EXIT INT QUIT TERM
for item in $backup_items
do
eval type=\$${item}_type
${type}_backup $item
done
trap - EXIT INT QUIT TERM
runhook epilogue_hook
logit "finished"
# finis coronat opus