aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Make.rules2
-rw-r--r--Makefile.am2
-rw-r--r--NEWS6
-rw-r--r--README4
-rw-r--r--backup.in100
-rw-r--r--beam.in77
-rwxr-xr-xcleaner.in85
-rw-r--r--configure.ac2
-rw-r--r--doc/Makefile.am2
-rw-r--r--doc/beam-backup.1in4
-rw-r--r--doc/beam-cleaner.1in4
-rw-r--r--doc/beam-list.1in4
-rw-r--r--doc/beam-module.5in4
-rw-r--r--doc/beam-restore.1in4
-rw-r--r--doc/beam-s3.1in4
-rw-r--r--doc/beam.1in4
-rw-r--r--lib/beam/Makefile.am2
-rw-r--r--lib/beam/common.in264
-rwxr-xr-xlib/beam/fs.sh186
-rwxr-xr-xlib/beam/ldap.sh2
-rwxr-xr-xlib/beam/postgres.sh106
-rw-r--r--lib/beam/s3.sh114
-rw-r--r--list.in68
-rw-r--r--restore.in104
-rw-r--r--s3.in58
25 files changed, 622 insertions, 590 deletions
diff --git a/Make.rules b/Make.rules
index 186de06..cafa879 100644
--- a/Make.rules
+++ b/Make.rules
@@ -1,3 +1,3 @@
# This file is part of BEAM
-# Copyright (C) 2012 Sergey Poznyakoff
+# Copyright (C) 2012-2014 Sergey Poznyakoff
#
diff --git a/Makefile.am b/Makefile.am
index c65a39d..551f7b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,3 @@
# This file is part of BEAM
-# Copyright (C) 2012 Sergey Poznyakoff
+# Copyright (C) 2012-2014 Sergey Poznyakoff
#
diff --git a/NEWS b/NEWS
index 7ef3571..1671079 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,3 @@
-BEAM NEWS -- history of user-visible changes. 2013-08-05
-Copyright (C) 2012, 2013 Sergey Poznyakoff.
+BEAM NEWS -- history of user-visible changes. 2014-03-19
+Copyright (C) 2012-2014 Sergey Poznyakoff.
See the end of file for copying conditions.
@@ -46,3 +46,3 @@ Copyright information:
-Copyright (C) 2012, 2013 Sergey Poznyakoff.
+Copyright (C) 2012-2014 Sergey Poznyakoff.
diff --git a/README b/README
index c407c0a..9e7410c 100644
--- a/README
+++ b/README
@@ -1,3 +1,3 @@
BEAM README file.
-Copyright (C) 2012 Sergey Poznyakoff
+Copyright (C) 2012-2014 Sergey Poznyakoff
See the end of file for copying conditions.
@@ -114,3 +114,3 @@ Send bug reports to <gray@gnu.org.ua>.
-Copyright (C) 2012 Sergey Poznyakoff
+Copyright (C) 2012-2014 Sergey Poznyakoff
diff --git a/backup.in b/backup.in
index ca479b1..477b839 100644
--- a/backup.in
+++ b/backup.in
@@ -2,3 +2,3 @@
# This file is part of BEAM
-# Copyright (C) 2012 Sergey Poznyakoff
+# Copyright (C) 2012-2014 Sergey Poznyakoff
#
@@ -25,4 +25,4 @@ week=`date +%U`
if [ "$1" = "--wtf" ]; then
- wtf $(basename $0) create a backup
- exit 0
+ wtf $(basename $0) create a backup
+ exit 0
fi
@@ -38,5 +38,5 @@ taroptions="-c -Hpax $backup_tar_options $backup_rsh_command"
if [ -n "$backup_verbose" ]; then
- verbose=-v
+ verbose=-v
else
- verbose=
+ verbose=
fi
@@ -56,3 +56,3 @@ round=0
help() {
- cat <<EOF
+ cat <<EOF
usage: $0 [OPTIONS]
@@ -73,3 +73,3 @@ Report bugs to <@PACKAGE_BUGREPORT@>
EOF
- exit 0
+ exit 0
}
@@ -82,15 +82,15 @@ 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
@@ -98,25 +98,25 @@ 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"
}
@@ -127,14 +127,14 @@ 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
diff --git a/beam.in b/beam.in
index 480351c..7281a18 100644
--- a/beam.in
+++ b/beam.in
@@ -1,2 +1,17 @@
#! /bin/sh
+# This file is part of BEAM
+# 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.
+#
+# 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 <http://www.gnu.org/licenses/>.
@@ -8,3 +23,3 @@ set +e
help() {
- cat <<EOT
+ cat <<EOT
usage: beam COMMAND [OPTIONS] [ITEM [ITEM...]]
@@ -13,10 +28,10 @@ COMMANDS are:
EOT
- for cmd in @LIBEXECDIR@/beam-*
- do
- test -x $cmd && $cmd --wtf
- done
- wtf help display help page for a particular command
- echo ""
- echo "Report bugs to <@PACKAGE_BUGREPORT@>"
- exit 0
+ for cmd in @LIBEXECDIR@/beam-*
+ do
+ test -x $cmd && $cmd --wtf
+ done
+ wtf help display help page for a particular command
+ echo ""
+ echo "Report bugs to <@PACKAGE_BUGREPORT@>"
+ exit 0
}
@@ -25,10 +40,10 @@ while [ $# -ne 0 ]
do
- case $1 in
- -h|--help) help;;
- -V|--version) print_version;;
- --) shift; break;;
- -*) echo >&2 "$0: unrecognized option $1"; exit 1;;
- *) break;;
- esac
- shift
+ case $1 in
+ -h|--help) help;;
+ -V|--version) print_version;;
+ --) shift; break;;
+ -*) echo >&2 "$0: unrecognized option $1"; exit 1;;
+ *) break;;
+ esac
+ shift
done
@@ -36,4 +51,4 @@ done
if [ $# -eq 0 ]; then
- error "command not specified"
- abend 1 "try $0 --help for more details"
+ error "command not specified"
+ abend 1 "try $0 --help for more details"
fi
@@ -41,9 +56,9 @@ fi
if [ $1 = "help" ]; then
- shift
- if [ $# -eq 0 ]; then
- man 1 beam
- else
- man 1 beam-$1
- fi
- exit $?
+ shift
+ if [ $# -eq 0 ]; then
+ man 1 beam
+ else
+ man 1 beam-$1
+ fi
+ exit $?
fi
@@ -51,8 +66,8 @@ fi
if [ -x @LIBEXECDIR@/beam-$1 ]; then
- cmd=@LIBEXECDIR@/beam-$1
- shift
- $cmd $@
+ cmd=@LIBEXECDIR@/beam-$1
+ shift
+ $cmd $@
else
- error "unknown command"
- abend 1 "try $0 --help for more details"
+ error "unknown command"
+ abend 1 "try $0 --help for more details"
fi
diff --git a/cleaner.in b/cleaner.in
index 035892f..0a9a35f 100755
--- a/cleaner.in
+++ b/cleaner.in
@@ -1,2 +1,17 @@
#! /bin/sh
+# This file is part of BEAM
+# 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.
+#
+# 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 <http://www.gnu.org/licenses/>.
@@ -31,15 +46,15 @@ while [ $# -ne 0 ]
do
- case $1 in
- -s|--suffix) shift; suffix=$1;;
- -r|--retain) shift; retainweeks=$1;;
- -v|--verbose) verbose=echo;;
- -n|--dry-run) dry_run=echo; verbose=echo;;
- -h|--help) help;;
- --wtf) wtf $(basename $0) clean up old files; exit 0;;
- --) shift; break;;
- -*) echo >&2 "$0: unrecognized option $1"
- exit 1;;
- *) break
- esac
- shift
+ case $1 in
+ -s|--suffix) shift; suffix=$1;;
+ -r|--retain) shift; retainweeks=$1;;
+ -v|--verbose) verbose=echo;;
+ -n|--dry-run) dry_run=echo; verbose=echo;;
+ -h|--help) help;;
+ --wtf) wtf $(basename $0) clean up old files; exit 0;;
+ --) shift; break;;
+ -*) echo >&2 "$0: unrecognized option $1"
+ exit 1;;
+ *) break
+ esac
+ shift
done
@@ -47,7 +62,7 @@ done
case $# in
-0) echo >&2 "$0: not enough arguments"
- exit 1;;
-1) dir=$1;;
-*) echo >&2 "$0: too many arguments"
- exit 1;;
+ 0) echo >&2 "$0: not enough arguments"
+ exit 1;;
+ 1) dir=$1;;
+ *) echo >&2 "$0: too many arguments"
+ exit 1;;
esac
@@ -60,5 +75,5 @@ thisweek=$(date +%U)
if [ $thisweek -gt $retainweeks ]; then
- lastweek=$(expr $thisweek - $retainweeks)
+ lastweek=$(expr $thisweek - $retainweeks)
else
- lastweek=$(expr $thisweek + 54 - $retainweeks)
+ lastweek=$(expr $thisweek + 54 - $retainweeks)
fi
@@ -68,5 +83,5 @@ $verbose \# removing from $dir files ending in $suffix and older than week $last
if [ -z "$suffix" ]; then
- find $dir -maxdepth 1 -type f -printf '%f\n'
+ find $dir -maxdepth 1 -type f -printf '%f\n'
else
- find $dir -maxdepth 1 -type f -name "*$suffix" -printf '%f\n'
+ find $dir -maxdepth 1 -type f -name "*$suffix" -printf '%f\n'
fi |
@@ -74,15 +89,15 @@ fi |
do
- $verbose \# considering $name
- week=$(expr "$name" : '[^-][^-]*-\([0-9][0-9]*\)-.*')
- if [ $thisweek -ge $week ]; then
- if [ $(expr $thisweek - $week) -gt $retainweeks ]; then
- $verbose \# removing $name
- $dry_run rm $dir/$name
- fi
- else
- if [ $(expr $thisweek + 54 - $week) -gt $retainweeks ]; then
- $verbose \# removing $name
- $dry_run rm $dir/$name
- fi
- fi
+ $verbose \# considering $name
+ week=$(expr "$name" : '[^-][^-]*-\([0-9][0-9]*\)-.*')
+ if [ $thisweek -ge $week ]; then
+ if [ $(expr $thisweek - $week) -gt $retainweeks ]; then
+ $verbose \# removing $name
+ $dry_run rm $dir/$name
+ fi
+ else
+ if [ $(expr $thisweek + 54 - $week) -gt $retainweeks ]; then
+ $verbose \# removing $name
+ $dry_run rm $dir/$name
+ fi
+ fi
done
diff --git a/configure.ac b/configure.ac
index a90c938..6e39a4a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,3 +1,3 @@
# This file is part of BEAM -*- autoconf -*-
-# Copyright (C) 2012, 2013 Sergey Poznyakoff
+# Copyright (C) 2012-2014 Sergey Poznyakoff
#
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 846c1de..0d82900 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,3 @@
# This file is part of BEAM
-# Copyright (C) 2012 Sergey Poznyakoff
+# Copyright (C) 2012-2014 Sergey Poznyakoff
#
diff --git a/doc/beam-backup.1in b/doc/beam-backup.1in
index be45a44..2438d7b 100644
--- a/doc/beam-backup.1in
+++ b/doc/beam-backup.1in
@@ -1,3 +1,3 @@
.\" This file is part of BEAM -*- nroff -*-
-.\" Copyright (C) 2012 Sergey Poznyakoff
+.\" Copyright (C) 2012-2014 Sergey Poznyakoff
.\"
@@ -16,3 +16,3 @@
.\"
-.TH BEAM\-BACKUP 1 "October 24, 2012" "BEAM" "BEAM User Reference"
+.TH BEAM\-BACKUP 1 "March 19, 2014" "BEAM" "BEAM User Reference"
.SH NAME
diff --git a/doc/beam-cleaner.1in b/doc/beam-cleaner.1in
index 36f2de7..59a39b4 100644
--- a/doc/beam-cleaner.1in
+++ b/doc/beam-cleaner.1in
@@ -1,3 +1,3 @@
.\" This file is part of BEAM -*- nroff -*-
-.\" Copyright (C) 2012 Sergey Poznyakoff
+.\" Copyright (C) 2012-2014 Sergey Poznyakoff
.\"
@@ -16,3 +16,3 @@
.\"
-.TH BEAM\-CLEANER 1 "October 24, 2012" "BEAM" "BEAM User Reference"
+.TH BEAM\-CLEANER 1 "March 19, 2014" "BEAM" "BEAM User Reference"
.SH NAME
diff --git a/doc/beam-list.1in b/doc/beam-list.1in
index 0614e81..57aa537 100644
--- a/doc/beam-list.1in
+++ b/doc/beam-list.1in
@@ -1,3 +1,3 @@
.\" This file is part of BEAM -*- nroff -*-
-.\" Copyright (C) 2012 Sergey Poznyakoff
+.\" Copyright (C) 2012-2014 Sergey Poznyakoff
.\"
@@ -16,3 +16,3 @@
.\"
-.TH BEAM\-LIST 1 "October 24, 2012" "BEAM" "BEAM User Reference"
+.TH BEAM\-LIST 1 "March 19, 2014" "BEAM" "BEAM User Reference"
.SH NAME
diff --git a/doc/beam-module.5in b/doc/beam-module.5in
index f650c65..9ba239f 100644
--- a/doc/beam-module.5in
+++ b/doc/beam-module.5in
@@ -1,3 +1,3 @@
.\" This file is part of BEAM -*- nroff -*-
-.\" Copyright (C) 2012 Sergey Poznyakoff
+.\" Copyright (C) 2012-2014 Sergey Poznyakoff
.\"
@@ -16,3 +16,3 @@
.\"
-.TH BEAM\-MODULE 5 "January 16, 2013" "BEAM" "BEAM Programmer Reference"
+.TH BEAM\-MODULE 5 "March 19, 2014" "BEAM" "BEAM Programmer Reference"
.SH NAME
diff --git a/doc/beam-restore.1in b/doc/beam-restore.1in
index bbbfbba..6d24ad8 100644
--- a/doc/beam-restore.1in
+++ b/doc/beam-restore.1in
@@ -1,3 +1,3 @@
.\" This file is part of BEAM -*- nroff -*-
-.\" Copyright (C) 2012 Sergey Poznyakoff
+.\" Copyright (C) 2012-2014 Sergey Poznyakoff
.\"
@@ -16,3 +16,3 @@
.\"
-.TH BEAM\-RESTORE 1 "October 24, 2012" "BEAM" "BEAM User Reference"
+.TH BEAM\-RESTORE 1 "March 19, 2014" "BEAM" "BEAM User Reference"
.SH NAME
diff --git a/doc/beam-s3.1in b/doc/beam-s3.1in
index 68dc66b..a295270 100644
--- a/doc/beam-s3.1in
+++ b/doc/beam-s3.1in
@@ -1,3 +1,3 @@
.\" This file is part of BEAM -*- nroff -*-
-.\" Copyright (C) 2012 Sergey Poznyakoff
+.\" Copyright (C) 2012-2014 Sergey Poznyakoff
.\"
@@ -16,3 +16,3 @@
.\"
-.TH BEAM\-S3 1 "October 24, 2012" "BBE" "BBE User Reference"
+.TH BEAM\-S3 1 "March 19, 2014" "BBE" "BBE User Reference"
.SH NAME
diff --git a/doc/beam.1in b/doc/beam.1in
index fc15064..0fd3ce5 100644
--- a/doc/beam.1in
+++ b/doc/beam.1in
@@ -1,3 +1,3 @@
.\" This file is part of BEAM -*- nroff -*-
-.\" Copyright (C) 2012 Sergey Poznyakoff
+.\" Copyright (C) 2012-2014 Sergey Poznyakoff
.\"
@@ -16,3 +16,3 @@
.\"
-.TH BEAM 1 "October 24, 2012" "BEAM" "BEAM User Reference"
+.TH BEAM 1 "March 19, 2014" "BEAM" "BEAM User Reference"
.SH NAME
diff --git a/lib/beam/Makefile.am b/lib/beam/Makefile.am
index 22c9a12..81385ad 100644
--- a/lib/beam/Makefile.am
+++ b/lib/beam/Makefile.am
@@ -1,3 +1,3 @@
# This file is part of BEAM
-# Copyright (C) 2012 Sergey Poznyakoff
+# Copyright (C) 2012-2014 Sergey Poznyakoff
#
diff --git a/lib/beam/common.in b/lib/beam/common.in
index 4f2184b..94b4565 100644
--- a/lib/beam/common.in
+++ b/lib/beam/common.in
@@ -36,3 +36,3 @@ backup_tmp_dir=/tmp
error() {
- echo >&2 $0: $*
+ echo >&2 $0: $*
}
@@ -40,3 +40,3 @@ error() {
logit() {
- echo `date`: $*
+ echo `date`: $*
}
@@ -44,6 +44,6 @@ logit() {
abend() {
- ec=$1
- shift
- error $@
- exit $ec
+ ec=$1
+ shift
+ error $@
+ exit $ec
}
@@ -51,11 +51,11 @@ abend() {
beam_lock() {
- if [ -r $backup_pidfile ]; then
+ if [ -r $backup_pidfile ]; then
pid=$(head -n 1 $backup_pidfile)
if [ -z "$pid" ]; then
- abend 1 "pidfile $backup_pidfile exists but is unreadable or empty"
+ abend 1 "pidfile $backup_pidfile exists but is unreadable or empty"
fi
abend 1 "another beam process (pid $pid) is still running; exiting"
- fi
- echo $$ > $backup_pidfile || exit 1
- epilogue_hook="$epilogue_hook beam_unlock"
+ fi
+ echo $$ > $backup_pidfile || exit 1
+ epilogue_hook="$epilogue_hook beam_unlock"
}
@@ -63,3 +63,3 @@ beam_lock() {
beam_unlock() {
- rm -f $backup_pidfile
+ rm -f $backup_pidfile
}
@@ -67,10 +67,10 @@ beam_unlock() {
tarcode() {
- case $1 in
- 0) logit "success";;
- 1) logit "some files changed while being archived";;
- 2) logit "fatal error occurred, but trying to continue anyway"
- tarerror=$((tarerror + 1));;
- *) logit "unexpected error code $1"
- tarerror=$((tarerror + 1));
- esac
+ case $1 in
+ 0) logit "success";;
+ 1) logit "some files changed while being archived";;
+ 2) logit "fatal error occurred, but trying to continue anyway"
+ tarerror=$((tarerror + 1));;
+ *) logit "unexpected error code $1"
+ tarerror=$((tarerror + 1));
+ esac
}
@@ -78,65 +78,65 @@ tarcode() {
load_config() {
- local delayed_exit remote
-
- test -z "$BEAM_CONFIG" && BEAM_CONFIG=@SYSCONFDIR@/beam.conf
- if [ -r $BEAM_CONFIG ]; then
- . $BEAM_CONFIG
- else
- abend 1 "configuration file $BEAM_CONFIG does not exist or is unreadable"
- fi
+ local delayed_exit remote
- if [ -z "$backup_items" ]; then
- abend 1 "backup_items not specified"
- fi
-
- if [ -z "$backup_archive_dir" ]; then
- if [ -n "$backup_bucket_name" ]; then
- backup_archive_dir=$backup_mp_s3
+ test -z "$BEAM_CONFIG" && BEAM_CONFIG=@SYSCONFDIR@/beam.conf
+ if [ -r $BEAM_CONFIG ]; then
+ . $BEAM_CONFIG
else
- abend 1 "backup_archive_dir not set"
+ abend 1 "configuration file $BEAM_CONFIG does not exist or is unreadable"
fi
- fi
-
- delayed_exit=
- loaded_types=
- for item in $backup_items
- do
- eval type=\$${item}_type
- if [ -z "$type" ]; then
- error "${item}_type not set"
- delayed_exit=1
- continue
+
+ if [ -z "$backup_items" ]; then
+ abend 1 "backup_items not specified"
fi
+
+ if [ -z "$backup_archive_dir" ]; then
+ if [ -n "$backup_bucket_name" ]; then
+ backup_archive_dir=$backup_mp_s3
+ else
+ abend 1 "backup_archive_dir not set"
+ fi
+ fi
+
+ delayed_exit=
+ loaded_types=
+ for item in $backup_items
+ do
+ eval type=\$${item}_type
+ if [ -z "$type" ]; then
+ error "${item}_type not set"
+ delayed_exit=1
+ continue
+ fi
- if echo "$loaded_types" | grep -wq $type; then
- :
- elif [ -x $libdir/${type}.sh ]; then
- . $libdir/${type}.sh || delayed_exit=1
- loaded_types="$loaded_files
+ if echo "$loaded_types" | grep -wq $type; then
+ :
+ elif [ -x $libdir/${type}.sh ]; then
+ . $libdir/${type}.sh || delayed_exit=1
+ loaded_types="$loaded_files
$type"
- else
- error "$libdir/${type}.sh not found"
- delayed_exit=1
- fi
+ else
+ error "$libdir/${type}.sh not found"
+ delayed_exit=1
+ fi
- ${type}_check $item || delayed_exit=1
- done
+ ${type}_check $item || delayed_exit=1
+ done
- test -n "$delayed_exit" && abend 1 "aborting"
+ test -n "$delayed_exit" && abend 1 "aborting"
- tar_suffix=${backup_suffix:-.tar}
+ tar_suffix=${backup_suffix:-.tar}
- if [ -n "$backup_bucket_name" ]; then
- . @LIBDIR@/beam/s3.sh
- prologue_hook="s3_mount $prologue_hook"
- fi
+ if [ -n "$backup_bucket_name" ]; then
+ . @LIBDIR@/beam/s3.sh
+ prologue_hook="s3_mount $prologue_hook"
+ fi
- remote=${backup_archive_dir%%:*}
- if [ "$remote" != "$backup_archive_dir" ]; then
- beam_rsh="${backup_rsh:-ssh} $remote"
- backup_local_archive_dir=${backup_archive_dir#*:}
- else
- beam_rsh=
- backup_local_archive_dir=$backup_archive_dir
- fi
+ remote=${backup_archive_dir%%:*}
+ if [ "$remote" != "$backup_archive_dir" ]; then
+ beam_rsh="${backup_rsh:-ssh} $remote"
+ backup_local_archive_dir=${backup_archive_dir#*:}
+ else
+ beam_rsh=
+ backup_local_archive_dir=$backup_archive_dir
+ fi
}
@@ -154,9 +154,9 @@ beam_exec() {
runhook() {
- local hook_list
+ local hook_list
- eval hook_list=\$$1
- for hook in $hook_list
- do
- $hook
- done
+ eval hook_list=\$$1
+ for hook in $hook_list
+ do
+ $hook
+ done
}
@@ -164,4 +164,4 @@ runhook() {
print_version() {
- name=$(basename $0)
- cat <<EOF
+ name=$(basename $0)
+ cat <<EOF
$name (@PACKAGE_NAME@) @PACKAGE_VERSION@
@@ -172,3 +172,3 @@ There is NO WARRANTY, to the extent permitted by law.
EOF
- exit 0
+ exit 0
}
@@ -176,6 +176,6 @@ EOF
wtf() {
- l=`echo "${1#beam-}"|sed "s|.|.|g"`
- s=$(echo " " | sed "s|$l|${1#beam-}|")
- shift
- echo " $s $@"
+ l=$(echo "${1#beam-}"|sed "s|.|.|g")
+ s=$(echo " " | sed "s|$l|${1#beam-}|")
+ shift
+ echo " $s $@"
}
@@ -183,5 +183,5 @@ wtf() {
dry_mail() {
- echo "============================================================="
- cat -
- echo "============================================================="
+ echo "============================================================="
+ cat -
+ echo "============================================================="
}
@@ -190,27 +190,27 @@ dry_mail() {
mail_report() {
- : ${backup_mailer_program:=/usr/sbin/sendmail -oi -t -F $backup_sender_email}
- if [ -n "$dry_run" ]; then
- echo "Sending mail using $backup_mailer_program"
- backup_mailer_program=dry_mail
- fi
- if [ -z "$backup_sender_email" ]; then
- backup_sender_email=root@$(hostname)
- fi
- case $backup_sender_email in
- "<"*) ;;
- *) backup_sender_email="<$backup_sender_email>"
- esac
- if [ -n "$backup_sender_personal" ]; then
- case $backup_sender_personal in
- \"*) ;;
- *) backup_sender_personal="\"$backup_sender_personal\""
+ : ${backup_mailer_program:=/usr/sbin/sendmail -oi -t -F $backup_sender_email}
+ if [ -n "$dry_run" ]; then
+ echo "Sending mail using $backup_mailer_program"
+ backup_mailer_program=dry_mail
+ fi
+ if [ -z "$backup_sender_email" ]; then
+ backup_sender_email=root@$(hostname)
+ fi
+ case $backup_sender_email in
+ "<"*) ;;
+ *) backup_sender_email="<$backup_sender_email>"
esac
- backup_sender_personal="$backup_sender_personal "
- fi
- if [ -z "$backup_report_subject" ]; then
- backup_report_subject="Backup of $(hostname) on $(date)"
- fi
- test -n "$backup_report_signature" &&
- echo "$backup_report_signature" >> $report
- (cat - <<EOF
+ if [ -n "$backup_sender_personal" ]; then
+ case $backup_sender_personal in
+ \"*) ;;
+ *) backup_sender_personal="\"$backup_sender_personal\""
+ esac
+ backup_sender_personal="$backup_sender_personal "
+ fi
+ if [ -z "$backup_report_subject" ]; then
+ backup_report_subject="Backup of $(hostname) on $(date)"
+ fi
+ test -n "$backup_report_signature" &&
+ echo "$backup_report_signature" >> $report
+ (cat - <<EOF
From: ${backup_sender_personal}$backup_sender_email
@@ -222,11 +222,11 @@ X-Beam-Level: $level
EOF
- if [ -n "$backup_report_headers" ]; then
- echo "$backup_report_headers"
- fi
- echo ""
- if [ -n "$backup_report_intro" ]; then
- echo "$backup_report_intro"
- fi
- cat $report
-) | $backup_mailer_program
+ if [ -n "$backup_report_headers" ]; then
+ echo "$backup_report_headers"
+ fi
+ echo ""
+ if [ -n "$backup_report_intro" ]; then
+ echo "$backup_report_intro"
+ fi
+ cat $report
+ ) | $backup_mailer_program
}
@@ -234,11 +234,11 @@ EOF
beam_logrotate() {
- local conf=/tmp/beam-logrotate.conf u
- if test -z "$backup_logrotate_conf"; then
- backup_logrotate_conf="weekly
+ local conf=/tmp/beam-logrotate.conf u
+ if test -z "$backup_logrotate_conf"; then
+ backup_logrotate_conf="weekly
rotate 4
"
- fi
- u=$(umask)
- umask 077
- cat > $conf <<EOF
+ fi
+ u=$(umask)
+ umask 077
+ cat > $conf <<EOF
$backup_logfile {
@@ -248,6 +248,6 @@ missingok
EOF
- umask $u
- test -d @LOCALSTATEDIR@/lib/beam || mkdir @LOCALSTATEDIR@/lib/beam
- logrotate ${dry_run+-d} $verbose --state @LOCALSTATEDIR@/lib/beam/logrotate.state $conf
- rm $conf
+ umask $u
+ test -d @LOCALSTATEDIR@/lib/beam || mkdir @LOCALSTATEDIR@/lib/beam
+ logrotate ${dry_run+-d} $verbose --state @LOCALSTATEDIR@/lib/beam/logrotate.state $conf
+ rm $conf
}
diff --git a/lib/beam/fs.sh b/lib/beam/fs.sh
index b4d0c2d..015082b 100755
--- a/lib/beam/fs.sh
+++ b/lib/beam/fs.sh
@@ -2,3 +2,3 @@
# This file is part of BEAM
-# Copyright (C) 2012 Sergey Poznyakoff
+# Copyright (C) 2012-2014 Sergey Poznyakoff
#
@@ -30,26 +30,26 @@
initdb() {
- local filename
-
- if [ -n "$dry_run" ]; then
- logit "initializing snapshot for $1"
- return
- fi
-
- if [ $level -eq 0 ]; then
- filename=$backup_snapshot_dir/$1-$week-$round-$level.db
- test -r $filename && rm $filename
- else
- if [ $level -eq 1 ]; then
- filename=$backup_snapshot_dir/$1-$week-0-0.db
- else
- filename=$backup_snapshot_dir/$1-$week-$round-$((level - 1)).db
+ local filename
+
+ if [ -n "$dry_run" ]; then
+ logit "initializing snapshot for $1"
+ return
fi
- if [ -r $filename ]; then
- cp $filename $backup_snapshot_dir/$1-$week-$round-$level.db
- else
- logit "previous snapshot file $filename not found; falling back to level 0"
- filename=$backup_snapshot_dir/$1-$week-$round-$level.db
- test -r $filename && rm $filename
+
+ if [ $level -eq 0 ]; then
+ filename=$backup_snapshot_dir/$1-$week-$round-$level.db
+ test -r $filename && rm $filename
+ else
+ if [ $level -eq 1 ]; then
+ filename=$backup_snapshot_dir/$1-$week-0-0.db
+ else
+ filename=$backup_snapshot_dir/$1-$week-$round-$((level - 1)).db
+ fi
+ if [ -r $filename ]; then
+ cp $filename $backup_snapshot_dir/$1-$week-$round-$level.db
+ else
+ logit "previous snapshot file $filename not found; falling back to level 0"
+ filename=$backup_snapshot_dir/$1-$week-$round-$level.db
+ test -r $filename && rm $filename
+ fi
fi
- fi
}
@@ -58,10 +58,10 @@ initdb() {
fs_check() {
- local rc=0 root files
+ local rc=0 root files
- eval root=\$${1}_dir
- eval files=\$${1}_files
+ eval root=\$${1}_dir
+ eval files=\$${1}_files
- test -z "$root" && rc=1 && error "${1}_dir not set"
- test -z "$files" && rc=1 && error "${1}_files not set"
- return $rc
+ test -z "$root" && rc=1 && error "${1}_dir not set"
+ test -z "$files" && rc=1 && error "${1}_files not set"
+ return $rc
}
@@ -70,14 +70,14 @@ fs_check() {
fs_list() {
- local dir files lsf=
+ local dir files lsf=
- eval dir=\$${1}_dir files=\$${1}_files
- for file in $files
- do
- if [ -d "$dir/$file" ]; t