aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2017-02-16 08:42:02 +0200
committerSergey Poznyakoff <gray@gnu.org>2017-02-16 08:42:02 +0200
commit0cd31637a354ba5c0171a5f4ce8243f12739fda4 (patch)
treefc814571742f023778fa149138a486325dc51fdf
parentaa48c0113be59350159788f9efd43d8736e87dcb (diff)
downloadbeam-0cd31637a354ba5c0171a5f4ce8243f12739fda4.tar.gz
beam-0cd31637a354ba5c0171a5f4ce8243f12739fda4.tar.bz2
Starting rewrite in Perl
-rw-r--r--.gitignore27
-rw-r--r--Changes0
-rw-r--r--LICENSE (renamed from COPYING)0
-rw-r--r--MANIFEST7
-rw-r--r--Make.rules22
-rw-r--r--Makefile.PL26
-rw-r--r--Makefile.am73
-rw-r--r--backup.in144
-rw-r--r--beam.conf297
-rw-r--r--beam.in73
-rwxr-xr-xbootstrap3
-rwxr-xr-xcleaner.in117
-rw-r--r--configure.ac36
-rw-r--r--doc/.gitignore9
-rw-r--r--doc/Makefile.am55
-rw-r--r--doc/beam-backup.1in219
-rw-r--r--doc/beam-cleaner.1in77
-rw-r--r--doc/beam-list.1in74
-rw-r--r--doc/beam-module.5in278
-rw-r--r--doc/beam-restore.1in143
-rw-r--r--doc/beam-s3.1in87
-rw-r--r--doc/beam.1in146
-rw-r--r--doc/beam.conf.5in537
-rw-r--r--git2chg.awk76
-rw-r--r--lib/App/Beam/Config.pm455
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/beam/.gitignore1
-rw-r--r--lib/beam/Makefile.am33
-rw-r--r--lib/beam/common.in253
-rwxr-xr-xlib/beam/fs.sh148
-rwxr-xr-xlib/beam/ldap.sh164
-rwxr-xr-xlib/beam/mysql.sh175
-rwxr-xr-xlib/beam/postgres.sh102
-rw-r--r--lib/beam/s3.sh105
-rw-r--r--list.in101
-rw-r--r--restore.in165
-rw-r--r--s3.in85
-rw-r--r--t/config.t12
-rw-r--r--t/f.conf6
39 files changed, 607 insertions, 3725 deletions
diff --git a/.gitignore b/.gitignore
index 9124b80..a8e78c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,29 +1,12 @@
*~
.deps
.emacs*
-.libs
-ABOUT-NLS
-ChangeLog
-INSTALL
-Makefile
-Makefile.in
TAGS
-aclocal.m4
-autom4te.cache
-beam
-beam.sh
-build-aux
-cleaner.sh
-config.h
-config.h.in
-config.log
-config.status
-configure
core
-list.sh
-backup.sh
-restore.sh
-s3.sh
-build.sed
*.tar.*
tmp
+/MYMETA.json
+/MYMETA.yml
+Makefile
+/blib
+/pm_to_blib
diff --git a/Changes b/Changes
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Changes
diff --git a/COPYING b/LICENSE
index 94a9ed0..94a9ed0 100644
--- a/COPYING
+++ b/LICENSE
diff --git a/MANIFEST b/MANIFEST
new file mode 100644
index 0000000..211c165
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,7 @@
+Changes
+LICENSE
+MANIFEST
+Makefile.PL
+README
+lib/App/Beam/Config.pm
+
diff --git a/Make.rules b/Make.rules
deleted file mode 100644
index cafa879..0000000
--- a/Make.rules
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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/>.
-
-.in.sh:
- $(AM_V_GEN)sed -f $(top_builddir)/build.sed $< > $@
-.1in.1:
- $(AM_V_GEN)sed -f $(top_builddir)/build.sed $< > $@
-.5in.5:
- $(AM_V_GEN)sed -f $(top_builddir)/build.sed $< > $@
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..80f5548
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,26 @@
+use strict;
+use ExtUtils::MakeMaker;
+use Module::Metadata;
+
+WriteMakefile(NAME => 'App::Beam',
+ VERSION => '1.6.90',
+ AUTHOR => 'Sergey Poznyakoff <gray@gnu.org>',
+ LICENSE => 'gpl_3',
+ ABSTRACT => 'Backup tool',
+# EXE_FILES => [ 'beam' ],
+ MIN_PERL_VERSION => 5.006,
+ META_MERGE => {
+ 'meta-spec' => { version => 2 },
+ resources => {
+ repository => {
+ type => 'git',
+ url => 'git://git.gnu.org.ua/beam.git',
+ web => 'http://git.gnu.org.ua/cgit/beam.git/',
+ },
+ },
+ provides => Module::Metadata->provides(version => '1.4',
+ dir => 'lib')
+ }
+ );
+
+
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 551f7b2..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,73 +0,0 @@
-# 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/>.
-SUBDIRS=. lib doc
-if COND_S3MOUNT
- S3MOUNT=s3
- S3MOUNT_SH=s3.sh
-endif
-noinst_SCRIPTS=build.sed backup.sh restore.sh cleaner.sh list.sh $(S3MOUNT_SH)
-bin_SCRIPTS=beam
-CLEANFILES=beam beam.sh backup.sh restore.sh cleaner.sh list.sh $(S3MOUNT_SH)
-install-exec-hook:
- test -z "$(DESTDIR)$(libexecdir)" || \
- $(mkdir_p) "$(DESTDIR)$(libexecdir)"; \
- for file in backup restore cleaner list $(S3MOUNT); \
- do \
- ${INSTALL} $(top_builddir)/$$file.sh \
- $(DESTDIR)$(libexecdir)/beam-$$file; \
- done
-install-data-hook:
- test -z "$(DESTDIR)$(sysconfdir)" || \
- $(mkdir_p) "$(DESTDIR)$(sysconfdir)"; \
- if test -f $(DESTDIR)$(sysconfdir)/beam.conf; then :; else \
- ${INSTALL} -m 644 $(top_srcdir)/beam.conf $(DESTDIR)$(sysconfdir);\
- fi
-uninstall-hook:
- for file in backup restore cleaner list $(S3MOUNT); \
- do \
- rm -f "$(DESTDIR)$(libexecdir)/beam-$$file"; \
- done
-beam.sh backup.sh restore.sh cleaner.sh list.sh $(S3MOUNT_SH): build.sed
-EXTRA_DIST=beam.in backup.in restore.in beam.conf cleaner.in list.in s3.in
-distuninstallcheck_listfiles=find $(DESTDIR)$(prefix) -type f -not -wholename '$(DESTDIR)$(sysconfdir)/beam.conf'
-
-$(top_builddir)/build.sed: Makefile
- $(AM_V_GEN){ \
- echo 's|@''SYSCONFDIR''@|${sysconfdir}|g';\
- echo 's|@''LIBDIR''@|${libdir}|g'; \
- echo 's|@''BINDIR''@|${bindir}|g'; \
- echo 's|@''LIBEXECDIR''@|${libexecdir}|g'; \
- echo 's|@''LOCALSTATEDIR''@|${localstatedir}|g'; \
- echo 's|@''DATAROOTDIR''@|${datarootdir}|g'; \
- echo 's|@''PACKAGE_BUGREPORT''@|$(PACKAGE_BUGREPORT)|g'; \
- echo 's|@''PACKAGE_NAME''@|$(PACKAGE_NAME)|g';\
- echo 's|@''PACKAGE_STRING''@|$(PACKAGE_STRING)|g';\
- echo 's|@''PACKAGE_TARNAME''@|$(PACKAGE_STRING)|g';\
- echo 's|@''PACKAGE_URL''@|$(PACKAGE_URL)|g';\
- echo 's|@''PACKAGE_VERSION''@|$(PACKAGE_VERSION)|g';\
- } > $(top_builddir)/build.sed
-DISTCLEANFILES=build.sed backup.sh restore.sh list.sh
-include $(top_srcdir)/Make.rules
-
-.PHONY: ChangeLog
-ChangeLog:
- $(AM_V_GEN)if test -d .git; then \
- git log --pretty='format:%ct %an <%ae>%n%n%s%n%n%b%n' | \
- awk -f $(top_srcdir)/git2chg.awk > ChangeLog.tmp; \
- cmp ChangeLog ChangeLog.tmp > /dev/null 2>&1 || \
- mv ChangeLog.tmp ChangeLog; \
- rm -f ChangeLog.tmp; \
- fi
diff --git a/backup.in b/backup.in
deleted file mode 100644
index 477b839..0000000
--- a/backup.in
+++ /dev/null
@@ -1,144 +0,0 @@
-#! /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/>.
-
-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.
-unset 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
-
-Report bugs to <@PACKAGE_BUGREPORT@>
-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
-
-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 \
- ${dry_run+--dry-run} --suffix $backup_suffix $backup_archive_dir
- @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"
-}
-
-umask ${backup_umask:-077}
-prologue_hook="beam_lock $prologue_hook"
-
-if [ -n "$backup_logfile" ]; then
- runhook openlog_hook
- exec >>$backup_logfile
- exec 2>&1
-fi
-if [ -z "$backup_notify_email" ]; then
- backup
-else
- report=$backup_snapshot_dir/report.$$
- touch $report
- backup 2>&1 | tee $report
- mail_report $report
- rm $report
-fi
-
-
-# finis coronat opus
-
diff --git a/beam.conf b/beam.conf
index ce09da7..f0c595a 100644
--- a/beam.conf
+++ b/beam.conf
@@ -1,17 +1,3 @@
-# -*- shell-script -*-
-# This is a sample config file for the backup system. Tailor it to your
-# needs and remove the line below:
-echo >&2 "$0: WARNING: using default configuration boilerplate"
-
-# This file is essentially a shell script defining variables used by
-# the backup scripts. For a detailed information about it, see beam.conf(5)
-# To debug the configuration, run "beam backup --dry-run" and
-# "beam restore --dry-run".
-# For a detailed descriptions of these commands, see beam(1).
-
-PATH=/usr/sbin:$PATH
-export PATH
-
##########################################################################
# Hooks
##########################################################################
@@ -25,195 +11,104 @@ export PATH
# Commands listed in openlog_hook are run before opening the logfile. The
# most common use for this hook is to rotate an oversized logfile prior to
# opening it.
-#
-# Beam's default hook is beam_logrotate, which uses logrotate(8) to manage
-# the log file.
-openlog_hook=beam_logrotate
-# Additional configuration for logrotate can be supplied in the
-# backup_logrotate_conf variable.
-backup_logrotate_conf="weekly
-rotate 4
-"
+[hook openlog]
+ command = beam_logrotate
+
# The prologue_hook is a list of commands to run before starting backup
-# (or restore).
-prologue_hook=
+# (or restore).
+[hook prologue]
+ command =
# The epilogue_hook is a list of commands to run when the backup
# (or restore) finishes.
-epilogue_hook=
-
-##########################################################################
-# Archivation setup
-##########################################################################
-
-# Interval in weeks during which old backups and snapshots are retained.
-# If zero or empty, backups are retained forever.
-backup_retain_interval=
-
-# Directory for temporary files
-backup_tmp_dir=/tmp
-
-##########################################################################
-# S3 configuration.
-##########################################################################
-
-# To use S3 as the backup storage, define this variable to the name of the
-# bucket to keep backups in.
-backup_bucket_name=
-
-# Mountpoint for the raw bucket.
-backup_mp_s3backer=/mnt/s3backer
-# Mountpoint for the actual file system.
-backup_mp_s3=/mnt/s3
-
-# Additional options to pass to s3backer. The use of --vhost option
-# is advised if your bucket is located outside of the US region.
-backup_s3backer_options="--vhost"
-
-# Additional options to pass to mount(8)
-backup_s3_mount_options=
-
-##########################################################################
-# Tar setup.
-#
-# Tar setup variables configure invocation of tar.
-#
-##########################################################################
-
-# Any additional options to pass to tar. Do not place tar operation
-# switches (as -c, -t, etc.) here! These will be added automatically
-# by appropriate scripts, depending on the operation being performed.
-#
-# By default this variable is empty (no additional options).
-#
-# In this example it is used to request bzip2 compression:
-backup_tar_options="-j"
-
-# Suffix for archive files.
-# Default is "tar"
-#
-backup_suffix="tar.bz2"
-
-# Directory where archive files are to be located. It's OK to specify
-# a remote directory here, e.g. 10.10.0.1:/export/backup
-#
-# This variable must be set. Whatever directory it points to must already
-# exist, the backup script won't create it.
-#
-# The only exception to this is when backup_bucket_name is defined. In
-# that case, if backup_archive_dir is empty, it is assigned to the value
-# of backup_mp_s3 variable. This directory will be created, if needed.
-backup_archive_dir=/var/backups
-
-# Directory where to store snapshot files. The files will be named as
-# their archive counterparts, with the suffix ".db".
-#
-# This variable must be set
-backup_snapshot_dir=/var/lib/backups
-
-# Set this variable to a non-empty value if you wish backup procedures to
-# be verbose.
-backup_verbose=
-
-##########################################################################
-# Backup items.
-#
-# Backup items are symbolic names that identify abstract objects that
-# need to be backed up (or restored). These must be valid shell variable
-# names. For each backup item <name>, this configuration file defines a
-# set of variables which determine what files to backup and what methods
-# to use for that. Each such variable is named <name>_<variable>, where
-# <name> is the item name, and <variable> is the variable name. The set
-# of variables needed depends on the type of each particular item.
-#
-##########################################################################
-
-# The following are sample entries. Be sure to edit them
-
-# Define the list of items to back up.
-# This variable must be set.
-backup_items="dbdump system"
-
-# For each item in $backup_items, at least its type (variable <item>_type)
-# must be declared. Item type determines the mechanism used to back up
-# and restore it. Valid item types are:
-#
-# fs back up a file system
-# postgres back up a postgres database
-# mysql back up a mysql database
-# ldap back up an LDAP database
-#
-# You may define additional types, if you need. To do so, create an executable
-# file named <type>.sh in the directory @LIBDIR@/beam.
-#
-
-# Dump Postgres database "mydb".
-# The <item>_database is the only variable required by type "postgres".
-dbdump_type=postgres
-dbdump_database="mydb"
-
-# Back up directories in the file system.
-# The "fs" type requires at least to variables:
-#
-# <item>_dir specifies the directory (usually, but not necessarily a mount
-# point), under which the directories and files to be backed up are located.
-#
-# <item>_files specifies a list of directories and/or files in that directory.
-
-system_type=fs
-system_dir="/"
-system_files="etc var/spool"
-
-
-##########################################################################
-# Mail notification setup.
-#
-# Apart from usual logging, backup reports can be sent via email. To
-# enable this, define the variable "backup_notify_email" to the list
-# of emails that should receive the reports. Separate multiple addresses
-# with commas.
-#
-# A set of variables is provided to customize report headers and contents.
-##########################################################################
-
-# Comma-separated list of emails to send backup reports to. If emply,
-# mail notifications are not sent.
-backup_notify_email=
-
-# Sender email address. Backup reports will appear to be sent from this
-# address. The default value is root@$(hostname).
-# If set, this variable must contain a single email address, without
-# personal part or comments, e.g.
-# backup_sender_email=root@example.com
-backup_sender_email=
-
-# You can supply personal part of the sender email using this variable.
-# The personal part will be enclosed in double quotes and prepended to
-# the value of $backup_sender_email to form a valid RFC-2822 "From" header.
-# For example, if you have:
-# backup_sender_email=root@example.com
-# backup_sender_personal="Automatic backup report"
-# you will see the following in the report headers:
-# From: "Automatic backup report" <root@example.com>
-backup_sender_personal=
-
-# Supply any additional headers for the report message. By default, the
-# following headers are generated:
-# From, To, Subject, X-Beam-Items, X-Beam-Round and X-Beam-Level.
-# The three X- headers contain the backed up items (as set in the
-# backup_items variable), backup round and backup level numbers,
-# correspondingly.
-#
-# To supply multiple headers, delimit them with a single newline character.
-backup_report_headers=
-
-# The value of this variable is output before the actual report.
-backup_report_intro=
-
-# The value of this variable is added at the end of the report.
-backup_report_signature=
+[hook epilogue]
+ command =
+
+[core]
+ # Interval in weeks during which old backups and snapshots are
+ # retained.
+ # If zero or empty, backups are retained forever.
+ retain-interval =
+ # Directory for temporary files
+ tempdir = /tmp
+ # Set to On, if you wish backup procedures to be verbose.
+ verbose = On
+ # List of items to backup
+ items = dbdump system
+
+[tar]
+ # Thes variables configure invocation of tar.
+
+ # Any additional options to pass to tar. Do not place tar operation
+ # switches (as -c, -t, etc.) here! These will be added automatically
+ # by appropriate scripts, depending on the operation being performed.
+ #
+ # By default this variable is empty (no additional options).
+ #
+ options = -j
+
+ # Suffix for archive files.
+ # Default is "tar"
+ #
+ suffix = tar.bz2
+
+ # Directory where archive files are to be located. It's OK to specify
+ # a remote directory here, e.g. 10.10.0.1:/export/backup
+ #
+ # This variable must be set. Whatever directory it points to must
+ # already exist, the backup script won't create it.
+ archive-dir = /var/backups
+
+ # Directory where to store snapshot files. The files will be named as
+ # their archive counterparts, with the suffix ".db".
+ #
+ # This variable must be set
+ snapshot-dir = /var/lib/backups
+
+[item dbdump]
+ type = postgres
+ database = mydb
+
+[item system]
+ type = fs
+ directory = /
+ files = etc var/spool
+
+[report]
+ # Comma-separated list of emails to send backup reports to. If emply,
+ # mail notifications are not sent.
+ email =
+
+ # Sender email address. Backup reports will appear to be sent from
+ # this address. The default value is root@$(hostname).
+ # If set, this variable must contain a single email address, without
+ # personal part or comments, e.g.
+ sender =
+
+ # You can supply personal part of the sender email using this variable.
+ # The personal part will be enclosed in double quotes and prepended to
+ # the value of $backup_sender_email to form a valid RFC-2822 "From"
+ # header.
+ # For example, if you have:
+ # sender = root@example.com
+ # sender-personal = Automatic backup report
+ # you will see the following in the report headers:
+ # From: "Automatic backup report" <root@example.com>
+ sender-personal =
+
+ # Supply additional header for the report message. By default,
+ # the following headers are generated:
+ # From, To, Subject, X-Beam-Items, X-Beam-Round and X-Beam-Level.
+ # The three X- headers contain the backed up items (as set in the
+ # backup_items variable), backup round and backup level numbers,
+ # correspondingly.
+ #
+ # Multiple headers statements are OK
+ header = X-My-Info: ok
+
+ # Any text to be output before the actual report.
+ intro =
+
+ # Text to be added at the end of the report.
+ signature =
-# Reports are sent using this program. If not set, it defaults to
-# /usr/sbin/sendmail -oi -t -F $backup_sender_email
-# The generated report is piped to the standard input of this program.
-backup_mailer_program=
diff --git a/beam.in b/beam.in
deleted file mode 100644
index 7281a18..0000000
--- a/beam.in
+++ /dev/null
@@ -1,73 +0,0 @@
-#! /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/>.
-
-libdir=@LIBDIR@/beam
-set -e
-. $libdir/common.sh
-set +e
-
-help() {
- cat <<EOT
-usage: beam COMMAND [OPTIONS] [ITEM [ITEM...]]
-
-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
-}
-
-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
-done
-
-if [ $# -eq 0 ]; then
- error "command not specified"
- abend 1 "try $0 --help for more details"
-fi
-
-if [ $1 = "help" ]; then
- shift
- if [ $# -eq 0 ]; then
- man 1 beam
- else
- man 1 beam-$1
- fi
- exit $?
-fi
-
-if [ -x @LIBEXECDIR@/beam-$1 ]; then
- cmd=@LIBEXECDIR@/beam-$1
- shift
- $cmd $@
-else
- error "unknown command"
- abend 1 "try $0 --help for more details"
-fi
diff --git a/bootstrap b/bootstrap
deleted file mode 100755
index 263737c..0000000
--- a/bootstrap
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-# Run this file to bootstrap a checked-out version of sources.
-autoreconf -f -i -s
diff --git a/cleaner.in b/cleaner.in
deleted file mode 100755
index 1db87c1..0000000
--- a/cleaner.in
+++ /dev/null
@@ -1,117 +0,0 @@
-#! /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/>.
-
-libdir=@LIBDIR@/beam
-set -e
-. $libdir/common.sh
-set +e
-
-dir=
-suffix=
-retainweeks=3
-dry_run=
-verbose=:
-
-help() {
- cat <<EOF
-usage: $0 [OPTIONS] DIR
-cleans up old backup files in DIR
-
-OPTIONS are:
- -s, --suffix SUF consider only file names ending in SUF
- -r, --retain N retain N last weeks of backups (default $retainweeks)
- -v, --verbose verbosely list what is being done
- -n, --dry-run do nothing, print what would have been done
- -h, --help print this help list
-
-EOF
- exit 0
-}
-
-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
-done
-
-case $# in
- 0) echo >&2 "$0: not enough arguments"
- exit 1;;
- 1) dir=$1;;
- *) echo >&2 "$0: too many arguments"
- exit 1;;
-esac
-
-remote=${dir%%:*}
-if [ "$remote" != "$dir" ]; then
- beam_rsh="${backup_rsh:-ssh} $remote"
- localdir=${dir#*:}
-else
- beam_rsh=
- localdir=$dir
-fi
-
-thisweek=$(date +%U)
-
-# Warning: do not use shell arithmetic expansions on week numbers,
-# because weeks prior to 10 begin with 0 and therefore are processed
-# as octal numbers. This causes grief for weeks 08 and 09.
-if [ $thisweek -gt $retainweeks ]; then
- lastweek=$(expr $thisweek - $retainweeks)
-else
- lastweek=$(expr $thisweek + 54 - $retainweeks)
-fi
-
-$verbose \# removing from $dir files ending in $suffix and older than week $lastweek
-
-if [ -z "$suffix" ]; then
- beam_exec find $localdir -maxdepth 1 -type f -printf '%f>n'
-else
- beam_exec find $localdir -maxdepth 1 -type f -name "*$suffix" -printf '%f>n'
-fi |
- while read name
- do
- week=$(expr "$name" : '.*-\([0-9][0-9]*\)-[0-9][0-9]*-[0-9][0-9]*.*$')
- if [ $thisweek -ge $week ]; then
- if [ $(expr $thisweek - $week) -gt $retainweeks ]; then
- echo $localdir/$name
- fi
- else
- if [ $(expr $thisweek + 54 - $week) -gt $retainweeks ]; then
- echo $localdir/$name
- fi
- fi
- done |
- if [ -z "$dry_run" ]; then
- beam_exec xargs --no-run-if-empty rm
- else
- while read name
- do
- echo \# rm $name
- done
- fi
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 2a6e9e2..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,36 +0,0 @@
-# This file is part of BEAM -*- autoconf -*-
-# 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/>.
-
-AC_PREREQ(2.63)
-
-AC_INIT(beam, 1.5.90, gray@gnu.org.ua)
-AC_CONFIG_SRCDIR(backup.in)
-AC_CONFIG_AUX_DIR([build-aux])
-AM_INIT_AUTOMAKE([1.11 tar-ustar silent-rules])
-
-# Enable silent rules by default:
-AM_SILENT_RULES([yes])
-
-AC_ARG_WITH([s3],
- AC_HELP_STRING([--with-s3],
- [use s3 utilities]),
- [s3_status=$withval])
-AM_CONDITIONAL([COND_S3MOUNT],[test "$s3_status"=yes])
-
-AC_OUTPUT(Makefile
- lib/Makefile
- lib/beam/Makefile
- doc/Makefile)
diff --git a/doc/.gitignore b/doc/.gitignore
deleted file mode 100644
index 8b50b90..0000000
--- a/doc/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-beam.1
-beam-cleaner.1
-beam-backup.1
-beam-restore.1
-beam-cleanup.1
-beam-list.1
-beam-s3.1
-beam.conf.5
-beam-module.5
diff --git a/doc/Makefile.am b/doc/Makefile.am
deleted file mode 100644
index 0d82900..0000000
--- a/doc/Makefile.am
+++ /dev/null
@@ -1,55 +0,0 @@
-# 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/>.
-if COND_S3MOUNT
- S3=beam-s3.1
-endif
-man_MANS = \
- beam.1\
- beam.conf.5\
- beam-backup.1\
- beam-restore.1\
- beam-list.1\
- beam-cleaner.1\
- beam-module.5\
- $(S3)
-beam.1: beam.1in Makefile
-beam-backup.1: beam-backup.1in Makefile
-beam.conf.5: beam.conf.5in Makefile
-beam-restore.1: beam-restore.1in Makefile
-beam-list.1: beam-list.1in Makefile
-beam-s3.1: beam-s3.1in Makefile
-beam-cleanup.1: beam-cleanup.1in Makefile
-beam-module.5: beam-module.5in Makefile
-EXTRA_DIST=\
- beam.1in\
- beam-backup.1in\
- beam-restore.1in\
- beam-list.1in\
- beam.conf.5in\
- beam-cleaner.1\
- beam-module.5in\
- beam-s3.1in\
- crontab.weekly
-CLEANFILES=\
- beam.1\
- beam.conf.5\
- beam-backup.1\
- beam-restore.1\
- beam-list.1\
- beam-module.5\
- beam-s3.1\
- beam-cleanup.1
-include $(top_srcdir)/Make.rules
diff --git a/doc/beam-backup.1in b/doc/beam-backup.1in
deleted file mode 100644
index 2438d7b..0000000
--- a/doc/beam-backup.1in
+++ /dev/null
@@ -1,219 +0,0 @@
-.\" This file is part of BEAM -*- nroff -*-
-.\" 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/>.
-.\"
-.TH BEAM\-BACKUP 1 "March 19, 2014" "BEAM" "BEAM User Reference"
-.SH NAME
-beam\-backup \- create a back up.
-.SH SYNOPSIS
-.B beam backup
-[\fB\-vnN\fR] [\fB\-\-verbose\fR] [\fB\-l\fR \fIFILE\fR]\
- [\fB\-\-logfile\fR \fIFILE\fR]\
- [\fB\-\-dry\-run\fR]
- [\fB\-L\fR \fIN\fR] [\fB\-\-level\fR \fIN\fR]
- [\fB\-R\fR \fIN\fR] [\fB\-\-round\fR \fIN\fR] [\fB\-\-week\fR \fIN\fR]
-
-.B beam backup
-[\fB\-h\fR] [\fB\-\-help\fR]
-
-.B beam backup
-[\fB\-V\fR] [\fB\-\-version\fR]
-.SH DESCRIPTION
-The
-.B beam\-backup
-command creates full or incremental backups of file systems and other
-objects described in its configuration file
-.BR beam.conf .
-The configuration file by default is searched in
-.BR @SYSCONFDIR@ .
-Another location can be specified by setting the environment variable
-.B BACKUP_CONFIG
-to the full pathname of the configuration file.
-.PP
-After loading the configuration file, the script examines its command
-line for options that modify its behavior. These are described in
-detail in the section
-.BR OPTIONS ,
-below.
-.PP
-The script uses
-.BR tar (1)
-to produce incremental backups. The produced archives are named using
-the following pattern:
-.sp
-.nf
-.in +2
-.BR ITEM \- WEEK \- ROUND \- LEVEL . SUFFIX
-.in
-.fi
-.sp
-where:
-.TP
-.B ITEM
-The name of the backup item. Backup items are defined in the
-configuration variable \fBbackup_items\fR and identify file systems
-(or other objects, such as PostgreSQL databases) to backup. See the
-section
-.B BACKUP ITEMS
-in
-.BR beam.conf (5),
-for a detailed description.
-.TP
-.B WEEK
-The number of week when this backup was taken. This is a number of
-week in year, formatted as a two-digit decimal number in the range 01
-to 53. Weeks are numbered starting with the first Sunday as the first
-day of week 01. For more details, see
-.BR strftime (3)
-conversion
-.BR %U .
-.TP
-.B ROUND
-The \fBround number\fR of this backup. This number identifies a
-particular series of incremental backups (starting at level 1), taken
-with respect to the same full backup.
-
-Consider for example the following backup schedule. A full backup is
-taken each Sunday. Then, during the week, incremental backups are
-taken daily: level one backup on Monday, level two backup on Tuesday,
-then again level one on Wednesday, and so on. In this scheme you get
-three rounds of backups each week. See the
-.B EXAMPLES
-section for an example of this schedule.
-.TP
-.B LEVEL
-Incremental level number.
-.TP
-.B SUFFIX
-The value of \fBbackup_suffix\fR configuration variable. If not set,
-.B tar
-is assumed.
-.PP
-The archives are stored in the directory specified by the
-.B backup_archive_dir
-configuration variable. This directory can be a local as well as a
-remote one. To use a remote location, set this variable to
-.sp
-.nf
-.in +2
-.BR HOST : DIR
-.in
-.fi
-.sp
-where
-.B HOST
-is the IP address or hostname of the remote machine, and
-.B DIR
-is the pathname on its file system. See the \fBThe GNU Tar Manual\fR,
-section 9.2 \fBRemote Tape Server\fR for more information on the subject.
-.PP
-The corresponding snapshots are stored in the directory specified by
-the \fBbackup_snapshot_dir\fR configuration variable and follow the
-same scheme as the archives, except that
-.B db
-is used as their suffix.
-.SH OPTIONS
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Increase verbosity. This overrides the \fBbackup_verbose\fR
-configuration variable.
-.TP
-\fB\-l\fR, \fB\-\-logfile\fR \fIFILE\fB
-Log to FILE. This overrides the \fBbackup_logfile\fR configuration
-variable.
-.TP
-\fB\-n\fR, \fB\-\-dry\-run
-Do nothing, print what would have been done. This option also implies
-.BR \-\-no\-logfile .
-
-Useful to debug your configuration.
-.TP
-\fB\-N\fR, \fB\-\-no\-logfile
-Do not use \fBbackup_logfile\fR variable, log to standard error
-instead.
-.TP
-\fB\-L\fR, \fB\-\-level \fIN\fR
-Create incremental dump level \fIN\fR.
-.TP
-\fB-R\fR, \fB\-\-round \fIN\fR
-Mark archives with incremental round number \fIN\fR.
-.TP
-\fB\-\-week \fIN\fR
-Force using week number \fIN\fR. By default, the current week number
-(as returned by
-.BR strftime (3)
-conversion
-.BR %U )
-is used.
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Display a short help summary.
-.TP
-\fB\-V\fR, \fB\-\-version\fR
-Display program version.
-.SH EXAMPLES
-Usually \fBbackup\fR is started as a cron job. The following
-example shows a root crontab designed so as to create full (level 0)
-backups on Sundays, level 1 backups on Mondays, Wednesdays and Fridays
-and level 2 backups on Tuesdays, Thursdays and Saturdays.
-.sp
-.nf
-.in +2
-# Create one full backup weekly.
-0 3 * * sun beam backup \-\-round 0 \-\-level 0
-# Create incremental backups daily.
-0 3 * * mon beam backup \-\-round 0 \-\-level 1
-0 3 * * tue beam backup \-\-round 0 \-\-level 2
-0 3 * * wed beam backup \-\-round 1 \-\-level 1
-0 3 * * thu beam backup \-\-round 1 \-\-level 2
-0 3 * * fri beam backup \-\-round 2 \-\-level 1
-0 3 * * sat beam backup \-\-round 2 \-\-level 2
-.in
-.fi
-.sp
-.SH FILES
-.TP
-.BR @SYSCONFDIR@/beam.conf
-Default configuration file.
-.TP
-.BR @LIBDIR@/beam
-Backup module directory. Whenever a beam item of type \fBT\fR is
-requested, \fBbeam\fR will attempt to load from this directory a
-file named \fBT.sh\fR. This file provides methods and definitions
-necessary to handle that particular item type.
-.TP
-.BR @LIBDIR@/beam/common.sh
-Settings and definitions shared between
-.BR beam\-backup ,
-.BR beam\-restore (1),
-and
-.BR beam\-list (1).
-.SH "SEE ALSO"
-.BR beam (1),
-.BR beam\-restore (1),
-.BR beam\-list (1),
-.BR beam.conf (5).
-.SH AUTHORS
-Sergey Poznyakoff
-.SH "BUG REPORTS"
-Report bugs to <@PACKAGE_BUGREPORT@>.
-.\" Local variables:
-.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_\\-]* [0-9] \""
-.\" time-stamp-format: "%:B %:d, %:y"
-.\" time-stamp-end: "\""
-.\" time-stamp-line-limit: 20
-.\" end:
-
diff --git a/doc/beam-cleaner.1in b/doc/beam-cleaner.1in
deleted file mode 100644
index 59a39b4..0000000
--- a/doc/beam-cleaner.1in
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" This file is part of BEAM -*- nroff -*-
-.\" 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/>.
-.\"
-.TH BEAM\-CLEANER 1 "March 19, 2014" "BEAM" "BEAM User Reference"
-.SH NAME
-beam\-cleaner \- clean up old backup files.
-.SH SYNOPSIS
-.B beam\-cleaner
-[\fB\-s\fR \fISUF\fR] [\fB\-r\fR \fIN\fs] [\fB\-vn\fR] \
- [\fB\-\-suffix\fR \fISUF\fR] [\fB\-\-retain\fR \fIN\fR] \
- [\fB\-\-verbose\fR] [\fB\-\-dry\-run\fR] \fBDIR\fR
-
-.B beam\-cleaner
-[\fB\-h\fR] [\fB\-\-help\fR]
-.SH DESCRIPTION
-.B Beam\-cleaner
-is an auxiliary utility run by
-.BR beam\-backup (1)
-to remove outdated backup or snapshot files from
-.BR DIR .
-The tool measures file creation dates in weeks, from the beginning of
-year and relies on file naming convention described in
-.BR beam\-backup (1)
-to determine them.
-.PP
-It deletes those files which are older than \fBN\fR weeks (\fBN\fR being
-supplied with the
-.B \-\-retain
-option).
-.PP
-Any files with names not matching the
-.BR beam\-backup (1)
-naming scheme are ignored.
-.SH OPTIONS
-.TP
-\fB\-s\fR, \fB\-\-suffix\fR \fISUF\fR
-Consider only file names ending in \fBSUF\fR.
-.TP
-\fB\-r\fR, \fB\-\-retain\fR \fIN\fS
-Retain \fIN\fR last weeks of backups (default 3).
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Verbosely list what is being done.
-.TP
-\fB\-n\fR, \fB\-\-dry\-run\fR
-Do nothing, print what would have been done.
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Print a terse help list.
-.SH "SEE ALSO"
-.BR beam (1),
-.BR beam\-backup (1),
-.BR beam.conf (5).
-.SH AUTHORS
-Sergey Poznyakoff
-.SH "BUG REPORTS"
-Report bugs to <@PACKAGE_BUGREPORT@>.
-.\" Local variables:
-.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_\\-]* [0-9] \""
-.\" time-stamp-format: "%:B %:d, %:y"
-.\" time-stamp-end: "\""
-.\" time-stamp-line-limit: 20
-.\" end:
diff --git a/doc/beam-list.1in b/doc/beam-list.1in
deleted file mode 100644
index 57aa537..0000000
--- a/doc/beam-list.1in
+++ /dev/null
@@ -1,74 +0,0 @@
-.\" This file is part of BEAM -*- nroff -*-
-.\" 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/>.
-.\"
-.TH BEAM\-LIST 1 "March 19, 2014" "BEAM" "BEAM User Reference"
-.SH NAME
-beam\-list \- list items included in backup
-.SH SYNOPSIS
-.B beam list
-[\fB\-l\fR] [\fB\-\-number\fR]
-
-.B beam list
-[\fB\-h\fR] [\fB\-\-help\fR]
-
-.B beam list
-[\fB\-V\fR] [\fB\-\-version\fR]
-.SH DESCRIPTION
-The command
-.B beam list
-produces a list of items included in the backup.
-.SH OPTIONS
-.TP
-.BR \-l , \-\-number
-Produce a numbered list.
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Display a short help summary.
-.TP
-\fB\-V\fR, \fB\-\-version\fR
-Display program version.
-.SH FILES
-.TP
-.BR @SYSCONFDIR@/beam.conf
-Default configuration file.
-.TP
-.BR @LIBDIR@/beam
-Backup module directory. Whenever a beam item of type \fBT\fR is
-requested, \fBbeam\fR will attempt to load from this directory a
-file named \fBT.sh\fR. This file provides methods and definitions
-necessary to handle that particular item type.
-.TP
-.BR @LIBDIR@/beam/common.sh
-Settings and definitions shared between this command,
-.BR beam\-backup (1)
-and
-.BR beam\-restore (1).
-.SH "SEE ALSO"
-.BR beam (1),
-.BR beam\-restore (1),
-.BR beam\-backup (1),
-.BR beam.conf (5).
-.SH AUTHORS
-Sergey Poznyakoff
-.SH "BUG REPORTS"
-Report bugs to <@PACKAGE_BUGREPORT@>.
-.\" Local variables:
-.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_\\-]* [0-9] \""
-.\" time-stamp-format: "%:B %:d, %:y"
-.\" time-stamp-end: "\""
-.\" time-stamp-line-limit: 20
-.\" end:
diff --git a/doc/beam-module.5in b/doc/beam-module.5in
deleted file mode 100644
index 9ba239f..0000000
--- a/doc/beam-module.5in
+++ /dev/null
@@ -1,278 +0,0 @@
-.\" This file is part of BEAM -*- nroff -*-
-.\" 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/>.
-.\"
-.TH BEAM\-MODULE 5 "March 19, 2014" "BEAM" "BEAM Programmer Reference"
-.SH NAME
-beam\-module \- format of
-.BR beam (1)
-modules
-.SH DESCRIPTION
-This manual page explains how to write new modules for
-.BR beam (1).
-.PP
-.B Beam
-is a modular backup system written in shell. It is mainly designed to
-create incremental backups of file systems using
-.BR tar (1),
-and restore from such backups. However, there are special kinds of
-data that cannot be reliably backed up using this method. An example
-of these are SQL databases. Simply archiving the database files while
-the database engine is running is not likely to produce a reliable
-backup \- such files will most probably be in inconsistent state,
-because of eventual transactions not being finished at the time of the
-backup. While stopping the database for the duration of the backup
-could produce a consistent backup, it is usually not an option. The
-obvious solution in this case is to create a database
-.B dump
-using the DBMS-specific software, and archive the created file or files.
-.PP
-To handle such cases,
-.B beam
-introduces a special entity, called
-.BR "backup item" .
-.SS Backup items
-A backup item is a set of data that are backed up and restored using a
-particular
-.BR method .
-.PP
-In
-.B beam
-configuration, backup items are identified by unique names. The
-method used to back up an item is defined by the \fIitem\fB_type\fR
-configuration keyword.
-.SS Modules
-For each backup method, defined by \fIitem\fB_type\fR keywords,
-.B beam
-looks for a shell script, called \fImethod\fB.sh\fR and located in the
-.B @LIBDIR@/beam
-directory.
-.PP
-For example, if the configuration file contains:
-.sp
-.nf
-.in +2
-backup_items="cfg db"
-
-cfg_type=fs
-db_type=mysql
-.in
-.fi
-.sp
-then the following files will be loaded:
-
- @LIBDIR@/beam/fs.sh
- @LIBDIR@/beam/mysql.sh
-
-.PP
-These files should provide the functions used to list, back up and
-restore the corresponding items.
-.SH MODULE FILE FORMAT
-Each module file must define the following functions (\fIname\fR
-stands for the name of the module):
-.TP
-.BR \fIname\fB_check( item )
-This function is called once for each backup item before starting
-backup or restore. Its purpose is to check whether the configuration
-for that particular item is correct (e.g. whether all the mandatory
-configuration keywords are defined and have consistent values, etc.)
-
-If the configuration is correct, the function shall return
-.BR 0 .
-Otherwise, it shall produce appropriate diagnostic messages using
-.B error
-or
-.B abend
-(see below) and return a non-zero value.
-
-As an example, consider the
-.B check
-function from the
-.B fs
-module. It verifies whether the two mandatory parameters,
-\fIitem\fB_dir\fR and \fIitem\fB_files\fR, are defined:
-.sp
-.nf
-.in +2
-fs_check() {
- local rc=0 root 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
-}
-.in
-.fi
-.TP
-.BR \fIname\fB_list( item , prefix )
-Produces a listing of the
-.B item
-prefixed by
-.B prefix .
-
-This function is used by the
-.B beam list
-command (see
-.BR beam\-list (1)).
-
-The following is a simplified example from the
-.B fs
-module:
-.sp
-.nf
-.in +2
-fs_list() {
- local dir files
-
- eval dir=\\$${1}_dir files=\\$${1}_files
- echo "${2}Files and directories in $dir:$files"
-}
-.in
-.fi
-.TP
-.BR \fIname\fB_backup( item )
-This function backs up the given
-.BR item .
-
-A very simplified version from
-the
-.B fs
-module illustrates this:
-.sp
-.nf
-.in +2
-fs_backup() {
- local basename text root files exclude addopts s e
-
- basename=$1\-$week\-$round\-$level
- eval dir=\\$${1}_dir files=\\$${1}_files
-
- $dry_run tar $verbose $taroptions \\
- \-f $backup_archive_dir/$basename.$tar_suffix \\
- \-\-listed=$backup_snapshot_dir/$basename.db \\
- \-C $dir $files
-}
-.TP
-.BR \fIname\fB_restore( item )
-This function does the opposite to \fIname\fB_backup\fR: it restores
-the given item from the backup.
-.SH VARIABLES
-Apart from the variables defined in
-.BR beam.conf (5),
-a module can access the following ones:
-.TP
-.B week
-Number of the current week in year, as a two-digit decimal number in
-the range 01 to 53. Weeks are numbered starting with the first Sunday
-as the first day of week 01. For more details, see
-.BR strftime (3)
-conversion
-.BR %U .
-.TP
-.B round
-Number of this backup round. See
-.BR beam\-backup (1),
-for a detailed discussion.
-.TP
-.B level
-Incremental level of this backup.
-.TP
-.B dry_run
-If the
-.B dry\-run
-module is enabled, the value of this variable is
-.BR echo ,
-otherwise it is empty. Place this variable in front of a shell
-command to ensure it will be printed, but not executed when in
-.B dry\-run
-mode. For example:
-.sp
-.nf
-.in +2
- $dry_run rm $dbdir/*
-.in
-.fi
-.sp
-The
-.B dry\-run
-mode is enabled by the
-.BR \-\-dry\-run " or " \-n
-option to
-.BR beam\-backup (1)
-and
-.BR beam\-restore (1).
-.TP
-.B verbose
-In verbose mode, the value of this variable is
-.BR \-v ,
-otherwise it is empty. Most programs use the
-.B \-v
-option to enable the verbose mode, so this variable can be used in
-constructing their command lines, e.g.:
-.sp
-.nf
-.in +2
- $dry_run tar $verbose \-c \-f $archive .
-.in
-.fi
-.sp
-.TP
-.B tarerror
-Keeps the number of errors that occurred so far. Increase this
-variable when an error occurred, that cannot be fixed automatically by
-the module. See also the
-.B tarcode
-function below.
-.SH FUNCTIONS
-The following functions are available for use in modules:
-.TP
-.B logit
-Writes its arguments to the selected log stream. The resulting line
-is prefixed with the current date.
-.TP
-.B error
-Write its arguments to the standard error, prefixing the line with the
-current date.
-.TP
-.B abend
-This function takes 2 or more arguments. The first argument is a
-decimal number, treated as the shell exit code. The rest of arguments
-supplies a diagnostic message. The function writes that message to
-the standard error, and returns the supplied code to the shell.
-.TP
-.B tarcode
-The argument is a decimal return code from a
-.BR tar (1)
-invocation. The function prints a human-readable description of the
-error code and increases
-.B tarerror
-if it is equal to or greater than 2.
-.SH "SEE ALSO"
-.BR beam (1),
-.BR beam.conf (5).
-.SH AUTHORS
-Sergey Poznyakoff
-.SH "BUG REPORTS"
-Report bugs to <@PACKAGE_BUGREPORT@>.
-.\" Local variables:
-.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_\\-]* [0-9] \""
-.\" time-stamp-format: "%:B %:d, %:y"
-.\" time-stamp-end: "\""
-.\" time-stamp-line-limit: 20
-.\" end:
diff --git a/doc/beam-restore.1in b/doc/beam-restore.1in
deleted file mode 100644
index 6d24ad8..0000000
--- a/doc/beam-restore.1in
+++ /dev/null
@@ -1,143 +0,0 @@
-.\" This file is part of BEAM -*- nroff -*-
-.\" 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/>.
-.\"
-.TH BEAM\-RESTORE 1 "March 19, 2014" "BEAM" "BEAM User Reference"
-.SH NAME
-beam\-restore \- restore file system from a backup.
-.SH SYNOPSIS
-.B beam restore
-[\fB\-cntv\fR] [\fB\-\-confirm\fR] [\fB\-C\fR \fIDIR\fR]\
- [\fB\-\-directory\fR \fIDIR\fR] [\fB\-\-verbose\fR]
- [\fB\-\-dry\-run\fR] [\fB\-\-list\fR] [\fB\-\-logfile\fR \fIFILE\fR]\
- [\fB\-L\fR \fIN\fR] [\fB\-\-level\fR \fIN\fR]
- [\fB\-R\fR \fIN\fR] [\fB\-\-round\fR \fIN\fR] [\fB\-\-week\fR \fIN\fR]
- [\fBITEM\fR [\fBITEM\fR...]]
-
-.B beam restore
-[\fB\-h\fR] [\fB\-\-help\fR]
-
-.B beam restore
-[\fB\-V\fR] [\fB\-\-version\fR]
-.SH DESCRIPTION
-The
-.B beam-restore
-command restores the file system from incremental backups created
-using
-.BR beam "" backup (1).
-.PP
-The program reads its configuration from the file
-.B beam.conf
-located in the
-.B @SYSCONFDIR@
-directory, or from the file named in the environment variable
-.BR BACKUP_CONFIG .
-The configuration file must exist.
-.PP
-After loading the configuration file, the program examines its command
-line for options that modify its behavior. These are described in
-detail in the section
-.BR OPTIONS ,
-below.
-.PP
-Once the configuration loaded, the
-.B beam\-restore
-command determines which backup archives to use for restoring. Unless
-being requested otherwise by the command line options, the utility
-selects the most recent set of backup files.
-.PP
-Before starting the restore, the command displays the backup files it
-has selected and asks the user if he wishes to proceed. Empty line
-(the \fBCR\fR alone) or any word beginning with \fBY\fR
-(case-insensitive) is taken as affirmative. Otherwise, a negative
-answer is assumed and program terminates.
-.PP
-The program restores file systems and other backup items in the
-order they are listed in the \fBbackup_items\fR configuration
-variable. The \fBITEM\fR arguments override this default. If they
-are present, the program will restore only those items that are listed
-in the command line and exactly in the order they appear.
-.SH OPTIONS
-.TP
-\fB\-c\fR, \fB\-\-confirm\fR
-Do not ask for confirmation; run straight into restoring.
-.TP
-\fB\-C\fR, \fB\-\-directory\fR \fIDIR\fR
-Restore into directory \fIDIR\fR instead of \fB/\fR.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Increase verbosity.
-.TP
-\fB\-n\fR, \fB\-\-dry\-run\fR
-Do nothing, but print what would have been done.
-.TP
-\fB\-t\fR, \fB\-\-list\fR
-List archive files, instead of extracting from them.
-.TP
-\fB\-l\fR, \fB\-\-logfile\fR \fIFILE\fB
-Log to \fIFILE\fR instead of the standard error. This option implies
-\fB\-\-confirm\fR. Note also, that due to its specific nature
-.B restore
-ignores the \fBbackup_logfile\fR configuration setting.
-.TP
-\fB\-L\fR, \fB\-\-level\fR \fIN\fN
-Set incremental dump level to stop at.
-.TP
-\fB\-R\fR, \fB\-\-round\fR \fIN\fR
-Use archives from incremental round \fIN\fR.
-.TP
-\fB\-W\fR, \fB\-\-week\fR \fIN\fR
-Use archives from week \fIN\fR.
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Display a short help summary.
-.TP
-\fB\-V\fR, \fB\-\-version\fR
-Display program version.
-.SH EXAMPLES
-.SH FILES
-.TP
-.BR @SYSCONFDIR@/beam.conf
-Default configuration file.
-.TP
-.BR @LIBDIR@/beam
-Backup module directory. Whenever a backup item of type \fBT\fR is
-requested, \fBrestore\fR will attempt to load from this directory a
-file named \fBT.sh\fR. This file provides methods and definitions
-necessary to handle that particular item type.
-.TP
-.BR @LIBDIR@/beam/common.sh
-Settings and definitions shared between
-.BR beam\-backup (1),
-.BR beam\-restore ,
-and
-.BR beam\-list (1).
-.SH "SEE ALSO"
-.BR beam (1),
-.BR beam\-backup (1),
-.BR beam\-list (1),
-.BR beam.conf (5)
-.SH AUTHORS
-Sergey Poznyakoff
-.SH "BUG REPORTS"
-Report bugs to <@PACKAGE_BUGREPORT@>.
-.\" Local variables:
-.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_\\-]* [0-9] \""
-.\" time-stamp-format: "%:B %:d, %:y"
-.\" time-stamp-end: "\""
-.\" time-stamp-line-limit: 20
-.\" end:
-
diff --git a/doc/beam-s3.1in b/doc/beam-s3.1in
deleted file mode 100644
index a295270..0000000
--- a/doc/beam-s3.1in
+++ /dev/null
@@ -1,87 +0,0 @@
-.\" This file is part of BEAM -*- nroff -*-
-.\" 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/>.
-.\"
-.TH BEAM\-S3 1 "March 19, 2014" "BBE" "BBE User Reference"
-.SH NAME
-beam\-s3 \- manage a backup s3 bucket
-.SH SYNOPSIS
-.B beam s3
-mount
-
-.B beam s3
-umount
-
-.B beam s3
-status
-
-.B beam s3
-[\fB\-h\fR] [\fB\-\-help\fR] [\fB\-V\fR] [\fB\-\-version\fR]
-.SH DESCRIPTION
-The
-.B beam\-s3
-command mounts or unmounts the \fBs3\fR bucket configured by the
-.B backup_bucket_name
-variable in
-.BR beam.conf (5).
-.SH ARGUMENTS
-.TP
-.B mount
-Mount the bucket.
-.TP
-.BR umount , unmount
-Unmount the bucket.
-.TP
-.B status
-Show bucket status.
-.SH OPTIONS
-For consistency with other programs, the following options are understood:
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Display a short help summary.
-.TP
-\fB\-V\fR, \fB\-\-version\fR
-Display program version.
-.SH FILES
-.TP
-.BR @SYSCONFDIR@/beam.conf
-Default configuration file.
-.TP
-.BR @LIBDIR@/beam/common.sh
-A library of common
-.B beam
-functions.
-.TP
-.BR @LIBDIR@/beam/s3.sh
-The
-.B s3
-support library.
-.SH "SEE ALSO"
-.BR beam (1),
-.BR beam\-backup (1),
-.BR beam\-restore (1),
-.BR beam.conf (5).
-.SH AUTHORS
-Sergey Poznyakoff
-.SH "BUG REPORTS"
-Report bugs to <@PACKAGE_BUGREPORT@>.
-.\" Local variables:
-.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_\\-]* [0-9] \""
-.\" time-stamp-format: "%:B %:d, %:y"
-.\" time-stamp-end: "\""
-.\" time-stamp-line-limit: 20
-.\" end:
-
diff --git a/doc/beam.1in b/doc/beam.1in
deleted file mode 100644
index 0fd3ce5..0000000
--- a/doc/beam.1in
+++ /dev/null
@@ -1,146 +0,0 @@
-.\" This file is part of BEAM -*- nroff -*-
-.\" 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/>.
-.\"
-.TH BEAM 1 "March 19, 2014" "BEAM" "BEAM User Reference"
-.SH NAME
-beam \- a backup manager
-.SH SYNOPSIS
-.B beam
-backup [\fIoptions\fB]
-
-.B beam
-restore [\fIoptions\fB]
-
-.B beam
-list [\fIoptions\fB]
-
-.B beam
-s3 [\fIoptions\fB]
-
-.B beam
-help \fICOMMAND\fR
-
-.B beam
-[\fB\-h\fR] [\fB\-\-help\fR] [\fB\-V\fR] [\fB\-\-version\fR]
-.SH DESCRIPTION
-.BR B ackup
-.BR E asy
-.BR A nd
-.BR M anageable
-is a suite of backup programs written in reasonably portable shell language
-with the purpose of making backup process as easy as possible.
-.PP
-All backup operations are controlled by the
-.B beam
-utility, which acts as a dispatcher between programs responsible for
-particular tasks. The actual task is specified as a
-.BR command ,
-i.e. a command verb given as the first argument to the program.
-For example,
-.B beam backup
-creates a backup.
-.PP
-.B Beam
-operates on
-.BR backup " " items.
-An item is a set of files, which should be handled together. The way
-to handle these files during backup or restore is defined by the item
-.B type.
-For example, the basic item type is \fBfs\fR (file system),
-which implies archiving all files comprising the item into a single
-.BR tar (1)
-archive. There are special item types for MySQL and PostgreSQL
-databases, etc.
-.PP
-.B Beam
-is a modular system. New item types can easily be defined by
-providing a module which defines how they should be handled during
-backup and restore. A module is a shell script named after the item
-type and placed in the
-.B @LIBDIR@/beam
-directory.
-.PP
-The backup process is controlled by the configuration file
-.BR @SYSCONFDIR@/beam.conf .
-This file is a set of shell variable assignments which define the
-items to include in the backup.
-.PP
-For a detailed description of
-.B beam
-configuration file, backup item definitions and module system, see
-.BR beam.conf (5).
-.SH COMMANDS
-.TP
-.B backup
-Create a backup. See
-.BR beam\-backup (1).
-.TP
-.B restore
-Restore files from backup. See
-.BR beam\-restore (1).
-.TP
-.B list
-List items included in the backup. See
-.BR beam\-list (1).
-.TP
-.B s3
-Mount or unmount a backup s3 bucket. This command is available only
-if
-.B beam
-was configured with the
-.B \-\-with-s3
-option. See
-.BR beam\-s3 (1).
-.TP
-.BR help " " \fIcommand\fR
-Display help page for a particular \fIcommand\fR.
-.SH OPTIONS
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Display a short help summary.
-.TP
-\fB\-V\fR, \fB\-\-version\fR
-Display program version.
-.SH FILES
-.TP
-.B @SYSCONFDIR@/beam.conf
-Default configuration file.
-.TP
-.B @LIBDIR@/beam
-Backup module directory.
-.SH ENVIRONMENT
-.TP
-.B BEAM_CONFIG
-If defined, this variable supplies full pathname of the configuration
-file to use instead of the default
-.BR @SYSCONFDIR@/beam.conf .
-.SH "SEE ALSO"
-.BR beam\-backup (1),
-.BR beam\-restore (1),
-.BR beam\-s3 (1),
-.BR beam\-module (5),
-.BR beam.conf (5).
-.SH AUTHORS
-Sergey Poznyakoff
-.SH "BUG REPORTS"
-Report bugs to <@PACKAGE_BUGREPORT@>.
-.\" Local variables:
-.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_]* [0-9] \""
-.\" time-stamp-format: "%:B %:d, %:y"
-.\" time-stamp-end: "\""
-.\" time-stamp-line-limit: 20
-.\" end:
diff --git a/doc/beam.conf.5in b/doc/beam.conf.5in
deleted file mode 100644
index 9462035..0000000
--- a/doc/beam.conf.5in
+++ /dev/null
@@ -1,537 +0,0 @@
-.\" This file is part of BEAM -*- nroff -*-
-.\" 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/>.
-.\"
-.TH BEAM.CONF 5 "March 18, 2014" "BEAM" "BEAM User Reference"
-.SH NAME
-beam.conf \- configuration file for
-.B BEAM
-.SH DESCRIPTION
-The \fBbeam.conf\fR file defines what data are to be included in the
-backup, what backup methods to use and where to store the resulting
-archives. The
-.BR backup (1)
-and
-.BR restore (1)
-utilities expect to find it in the
-.B @SYSCONFDIR@
-directory.
-.SH SYNTAX
-The file is essentially a shell script that defines variables
-controlling backup and restore procedures. Names of the variables
-used by the backup scripts begin with
-.BR backup_ .
-.SH GENERAL SETUP
-.TP
-.BR backup_umask = \fIMASK\fR
-Sets file mode creation mask. This mask will apply to all files
-created during the backup: archives, snapshots and temporary files.
-The default mask is
-.BR 077 .
-.TP
-.BR backup_tmp_dir = \fIDIR\fR
-Sets the directory where temporary files will be stored. The default
-is
-.BR /tmp .
-.TP
-.BR backup_logfile = \fIFILE\fR
-If set, redirect standard error and standard output to that file. The
-file will be created if it does not exist. Otherwise, the output will be
-appended to it.
-
-By default, this file will be automatically rotated. See
-.B openlog_hook
-below for a discussion of this.
-.TP
-.BR backup_logrotate_conf = \fITEXT\fR
-Configuration text for
-.BR logrotate (8),
-used to rotate the logfile. The default corresponds to:
-.sp
-.nf
-.in +2
-backup_logrotate_conf = "
- weekly
- rotate 4"
-.in
-.fi
-.sp
-Note, that no block statements are allowed within
-.BR backup_logrotate_conf ,
-because its entire contents will be placed within an appropriate block
-statement.
-.TP
-.BR backup_rsh_command = \fICOMMAND\fR
-Use this command to access remote archives. Unless set, the backup
-utilities will first look for an executable file named
-.BR @BINDIR@/speedssh .
-If not found, they will fall back to using \fB/usr/bin/ssh\fR. It is
-the responsibility of the administrator to provide for authentication
-on the remote system, e.g. by using shared-key authentication.
-.TP
-.BR backup_retain_interval = \fINUMBER\fR
-Sets the interval, in weeks, during which old backups and snapshots
-are retained. Empty value or zero means never delete the backups.
-
-This variable is used by
-.BR backup (1),
-which calls
-.BR backup\-cleaner (1)
-if it is set.
-.SH S3 SETUP
-To keep archives in a
-.B s3
-bucket you will need the
-.BR s3backer (1)
-utility.
-.TP
-.BR backup_s3backer_options = \fILIST\fR
-Additional options for
-.BR s3backer (1).
-
-Use it, e.g., to pass the
-.B \-\-vhost
-option if your bucket is located outside of the US region.
-.TP
-.BR backup_bucket_name = \fISTRING\fR
-Sets the name of the
-.B s3
-bucket to keep the archives in.
-.TP
-.BR backup_mp_s3backer = \fIDIR\fR
-Defines mount point for the "raw" bucket.
-
-Default value is
-.BR /mnt/s3backer .
-.TP
-.BR backup_mp_s3 = \fIDIR\fR
-Defines mount point for the actual s3-backed filesystem.
-
-Default value is
-.BR /mnt/s3 .
-.SH TAR SETUP
-Tar setup variables control additional options and arguments passed to
-.BR tar (1).
-.TP
-.BR backup_tar_options = \fILIST\fR
-Use this variable to pass additional options to tar. Do not place tar
-operation switches (such as \fB-c\fR, \fB-t\fR, etc.) here! These
-will be added automatically by appropriate scripts, depending on the
-operation being performed.
-
-By default this variable is empty (no additional options passed to tar).
-.TP
-.BR backup_suffix = \fISTRING\fR
-This variable supplies suffix for created archive names. The default
-is
-.B tar .
-The dot is inserted between the file name and its suffix.
-
-This variable is useful if you request compression and want archive
-file names to reflect it. For example:
-.sp
-.nf
-.in +2
-backup_tar_options="\-j"
-backup_suffix="tar.bz2"
-.in
-.fi
-.sp
-.TP
-.BR backup_archive_dir = \fIDIR\fR
-Directory where archive files are located. It's OK to specify
-a remote directory here, e.g.
-.sp
-.nf
-.in +2
-backup_archive_dir="10.10.0.1:/export/backup"
-.in
-.fi
-.sp
-This variable must be defined and whatever directory it points to must
-already exist.
-
-If it is not defined and
-.B backup_bucket_name
-is set, indicating that the
-.B S3
-storage is used for backups,
-.B backup_archive_dir
-will be set automatically to the same value as
-.BR backup_mp_s3 .
-.TP
-.BR backup_snapshot_dir = \fIDIR\fR
-Directory for incremental snapshot files. These files are be named after
-their archive counterparts, by appending the
-.B .db
-suffix.
-.TP
-.BR backup_verbose = \fIN\fR
-Set this variable to any non-empty value to request additional
-verbosity. The effect of this setting depends on backup methods being
-used. For example, the
-.B fs
-method adds a
-.B \-v
-option to each invocation of
-.BR tar (1).
-.SH BACKUP ITEMS
-A
-.B backup item
-identifies information that needs to be backed up. Syntactically,
-items follow the same rules as shell variable names. Backup items
-are introduced using the following variable:
-.TP
-.BR backup_items = \fILIST\fR
-A whitespace-separated list of backup items.
-.PP
-For each backup item
-.I name
-the configuration file must provide a set of variables describing
-where to obtain this information and how to store it to the archive.
-These variables follow the same naming convention:
-.sp
-.nf
-.in +2
-\fIname\fR_\fBvar\fR
-.in
-.fi
-.sp
-where \fIname\fR is the item name and \fBvar\fR is a valid shell
-identifier.
-
-The \fIname\fR_\fBtype\fR variable must always be defined. It
-identifies the backup method to be applied to that item. The
-following backup methods are implemented:
-.TP
-.B fs
-A file system backup.
-.TP
-.B postgres
-Backup of PostgreSQL databases.
-.TP
-.B mysql
-Backup of MySQL databases.
-.TP
-.B ldap
-Backup of LDAP databases.
-.SH FS BACKUP TYPE
-This is the basic backup type. It creates incremental backups of a
-specified file system. For each item of this type, the following
-variables must be defined:
-.TP
-.BR \fIitem\fB_dir = \fIPATH\fR
-The absolute path to the file system being backed up.
-.TP
-.BR \fIitem\fB_files = \fILIST\fR
-A whitespace-separated list of directories and/or files in the
-.B \fIitem\fB_dir
-directory.
-.PP
-The following variables are optional:
-.TP
-.BR \fIitem\fB_exclude = \fILIST\fR
-A whitespace-separated list of file names (or
-.BR glob (3)
-patterns) to exclude from archivation. This is translated to
-a list of
-.B \-\-exclude
-options to
-.BR tar (1).
-Make sure to quote globbing patterns as you would have done in shell,
-to prevent them from being expanded too early. For example:
-.sp
-.nf
-.in +2
-system_exclude="'var/spool/mail/*'"
-.in
-.fi
-.sp
-.TP
-.BR \fIitem\fB_exclude_from = \fILIST\fR
-A list of files to read exclusion patterns from. It is translated
-into a list of
-.B \-\-exclude\-from
-options.
-.TP
-.BR \fIitem\fB_tar_options = \fILIST\fR
-A list of additional options to pass to tar. Use this with caution.
-.PP
-For example:
-.sp
-.nf
-.in +2
-backup_items="system"
-
-system_type=fs
-system_dir="/"
-system_files="etc var/spool"
-.in
-.fi
-.sp
-This configuration requests incremental backups of everything found in
-the directories \fB/etc\fR and \fB/var/spool\fR.
-.SH POSTGRES BACKUP TYPE
-The
-.B postgres
-type creates a dump of a PostgreSQL database and archives it using
-.BR tar (1).
-The following variables must be defined for items of this type:
-.TP
-.BR \fIitem\fB_database = \fISTRING\fR
-The database name.
-.SH MYSQL BACKUP TYPE
-The
-.B mysql
-backup type creates a dump of a MySQL database and archives it with
-.BR tar (1).
-The database to dump and access credentials are specified using the
-following variables:
-.TP
-.BR \fIitem\fB_alldb = single | monolithic | split | individual
-Determines how to dump databases if the \fIitem\fB_database\fR
-(see below) variable is not set. The value \fBsingle\fR or
-\fBmonolithic\fR means dump all databases to a single file named
-after the \fIitem\fR. This is the default. The value \fBsplit\fR
-or \fBindividual\fR instructs \fBbeam\fR to dump each database into
-a separate file, named
-.nh
-\fIitem\fB-\fIdbname\fB-\fIweek\fB-\fIround\fB-\fIlevel\fB.\fIsuffix\fR
-.hy
-.TP
-.BR \fIitem\fB_database = \fISTRING\fR
-The database name. If this variable is empty, all databases will be
-dumped.
-.TP
-.BR \fIitem\fB_defaults_file = \fIFILE\fR
-A full pathname of the MySQL defaults file which contains credentials for
-accessing this database. This file must have at least the
-.B mysqldump
-and
-.B mysql
-sections, the former being used when dumping the database and the
-latter when restoring it.
-.SH LDAP BACKUP TYPE
-A LDAP database is introduced with the
-.B ldap
-backup type. The following keywords specify what to backup:
-.TP
-.BR \fIitem\fB_database_directory = \fIDIR\fR
-Specifies the pathname of a directory that contains the database
-files. This is used at restore time to clean up old database contents
-prior to restoring it.
-.TP
-.BR \fIitem\fB_database_number = \fINUMBER\fR
-Number of the database to dump, if your LDAP configuration contains
-several databases. If absent, all databases will be dumped. This
-keyword cannot be used in conjunction with
-.B \fIitem\fB_database_suffix
-(see below).
-.TP
-.BR \fIitem\fB_database_suffix = \fISTRING\fR
-Use the specified suffix to determine which database to operate upon.
-.TP
-.BR \fIitem\fB_uri = \fIURI\fR
-Use dn, scope and filter from the supplied argument URI to handle
-only matching entries.
-.TP
-.BR \fIitem\fB_user = \fINAME\fR
-Restore the database with the privileges of this user.
-.TP
-.BR \fIitem\fB_slapcat_options = \fILIST\fR
-A list of additional options for
-.BR slapcat (8C).
-Use with caution.
-.TP
-.BR \fIitem\fB_slapadd_options = \fILIST\fR
-A list of additional options to pass to
-.BR slapadd (8C)
-when restoring from the backup.
-.SH MAIL NOTIFICATION
-Apart from usual logging, backup reports can be sent via email to
-selected recipients. To enable this feature, the variable
-.B backup_notify_email
-must be defined to a comma-separated list of recipient email
-addresses.
-.PP
-A number of variables is provided to customize the email headers and
-contents.
-.TP
-.BR backup_notify_email = \fILIST\fR
-Sets a list of emails to receive backup report. Multiple emails must
-be separated with commas. If not set, no notification will be sent.
-.TP
-.BR backup_sender_email = \fIEMAIL\fR
-Defines the sender email address. Backup reports will appear to be
-sent from this address. The default value is
-\fBroot\fR@\fIhostname\fR, when \fIhostname\fR is the name of the host
-on which the backup is run.
-
-If set, this variable must contain a single email address, without
-personal part or comments, e.g.
-.sp
-.nf
-.in +2
-backup_sender_email=root@example.com
-.in
-.fi
-.sp
-.TP
-.BR backup_sender_personal = \fISTRING\fR
-Defines personal part of the sender email. The personal part will be
-enclosed in double quotes and prepended to the value of
-.B backup_sender_email
-to form a valid RFC-2822
-.B From
-header. For example, if you have:
-.sp
-.nf
-.in +2
-backup_sender_email=root@example.com
-backup_sender_personal="Automatic backup report"
-.in
-.fi
-.sp
-then the resulting report will contain:
-.sp
-.nf
-.in +2
-From: "Automatic backup report" <root@example.com>
-.in
-.fi
-.sp
-.TP
-.BR backup_report_headers = \fILIST\fR
-Defines additional headers for the report message. By default, the
-following headers are generated:
-.BR From ,
-.BR To ,
-.BR Subject ,
-.BR X\-Beam\-Items ,
-.BR X\-Beam\-Round ,
-and
-.BR X\-Beam\-Level .
-The three \fBX\-\fR headers contain the backed up
-items (as set in the
-.B backup_items
-variable), backup round and backup level numbers, correspondingly.
-
-To supply multiple headers, delimit them with single newline characters.
-.TP
-.BR backup_report_intro = \fITEXT\fR
-Sets the introductory text to be displayed before the actual report.
-.TP
-.BR backup_report_signature = \fITEXT\fR
-Sets the signature text, which will be output after the report body.
-.TP
-.BR backup_mailer_program = \fICOMMAND\fR
-Defines the mailer program and its arguments. The default is
-.sp
-.nf
-.in +2
-/usr/sbin/sendmail \-oi \-t \-F $backup_sender_email
-.in
-.fi
-.sp
-.SH HOOKS
-Special variables, called hooks, allow you to supply arbitrary
-commands to be run at particular stages of the backup or restore process.
-.TP
-.BR openlog_hook = \fILIST\fR
-Commands listed in this variable are run before opening the logfile. The
-most common use for this hook is to rotate an oversized logfile prior to
-opening it.
-
-The default configuration file initializes this hook with
-.BR beam_logrotate ,
-a shell function that uses
-.BR logrotate (8)
-to manage the log file. Configuration for
-.BR logrotate (8)
-can be supplied in the
-.B backup_logrotate_conf
-variable. By default, the log file is rotated weekly and 4
-weeks worth of backlogs are preserved.
-.TP
-.BR prologue_hook = \fILIST\fR
-This variable contains a whitespace-separated list of commands to
-be invoked before starting backup (or restore). These commands are
-started in order of their appearance in the list and are called
-without arguments. By default, this variable is empty.
-.TP
-.BR epilogue_hook = \fILIST\fR
-This variable contains a whitespace-separated list of commands to
-be invoked after the backup (or restore) has finished. These commands are
-started in order of their appearance in the list and are called
-without arguments. By default, this variable is empty.
-.SH EXAMPLES
-A simple configuration file for backing up the contents of
-.BR /etc,
-.BR /home ,
-and the PostreSQL database
-.BR savane :
-.sp
-.nf
-.in +2
-# Request bzip2 compression:
-backup_tar_options="\-j"
-# Modify file name suffix accordingly
-backup_suffix="tar.bz2"
-# Write data to \fB/dev/rmt1\fR on a remote machine:
-backup_archive_dir=192.168.0.1:/dev/rmt1
-# Keep snapshots in this directory:
-backup_snapshot_dir=/var/snapshots
-
-# Two backup items are defined:
-backup_items="dbdump system"
-
-# The \fBdbdump\fR item dumps the database:
-dbdump_type=postgres
-dbdump_database=savane
-
-# The \fBsystem\fR item backs up the file system:
-system_type=fs
-system_dir="/"
-system_files="etc home"
-
-# Notify root about the results.
-backup_notify_email=root@example.com
-backup_sender_email=devnull@example.com
-backup_sender_personal="Automatic daily backup"
-backup_report_intro="Today's daily backup produced the following
-results."
-backup_report_signature="\-\-
-Best regards,
-Beam Automatic Backup"
-.in
-.fi
-.sp
-.SH "SEE ALSO"
-.BR beam (1),
-.BR beam\-restore (1),
-.BR beam\-backup (1),
-.BR beam\-cleaner (1).
-.SH AUTHORS
-Sergey Poznyakoff
-.SH "BUG REPORTS"
-Report bugs to <@PACKAGE_BUGREPORT@>.
-.\" Local variables:
-.\" eval: (add-hook 'write-file-hooks 'time-stamp)
-.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_.]* [0-9] \""
-.\" time-stamp-format: "%:B %:d, %:y"
-.\" time-stamp-end: "\""
-.\" time-stamp-line-limit: 20
-.\" end:
-
diff --git a/git2chg.awk b/git2chg.awk
deleted file mode 100644
index 166f6b2..0000000
--- a/git2chg.awk
+++ /dev/null
@@ -1,76 +0,0 @@
-# This file is part of grecs
-# Copyright (C) 2007, 2009-2012 Sergey Poznyakoff
-#
-# Grecs 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.
-#
-# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>.
-
-BEGIN {
- if (since)
- split(since,since_a,"-")
-}
-
-function timeok(t, a) {
- if (!since)
- return 1
- split(t,a,"-")
- if (a[1] < since_a[1])
- return 0
- if (a[1] >= since_a[1])
- return 1
- if (a[2] < since_a[2])
- return 0
- if (a[2] >= since_a[2])
- return 1
- return a[3] >= since_a[3]
-}
-
-/^[0-9]+ .* +<[^>]+>/ {
- s = strftime("%F", $1)
- if (!timeok(s))
- exit
- sub(/^[0-9]+ +/,"")
- if (s == datestr && author == $0)
- next
- datestr = s
- author = $0
- if (runlen) { runlen = 0; print "" }
- printf("%s %s\n", datestr, author)
- next
-}
-/^Signed-off-by:/ { next }
-/^git-svn-id:/ { next }
-/^<unknown>$/ { next }
-NF==0 {
- runlen++
- next
-}
-{ if (runlen) { runlen = 0; print "" }
- print "\t" $0 }
-
-END {
- if (append) {
- print ""
- while ((getline < append) > 0) {
- if (match($0, /^Local *Variables:/))
- break
- print
- }
- }
- print "\f"
- # Make sure Emacs won't recognize this line:
- print "Local", "Variables:"
- print "mode: change-log"
- print "version-control: never"
- print "buffer-read-only: t"
- print "End:"
-}
diff --git a/lib/App/Beam/Config.pm b/lib/App/Beam/Config.pm
new file mode 100644
index 0000000..dcc6137
--- /dev/null
+++ b/lib/App/Beam/Config.pm
@@ -0,0 +1,455 @@
+# Configuration parser for Beam -*- perl -*-
+# Copyright (C) 2016, 2017 Sergey Poznyakoff <gray@gnu.org>
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+package App::Beam::Config;
+
+use strict;
+use Carp;
+use File::stat;
+use Storable qw(retrieve store);
+use Data::Dumper;
+
+require Exporter;
+our @ISA = qw(Exporter);
+
+our $VERSION = "1.00";
+
+sub deferror {
+ my ($err) = @_;
+ carp "$err";
+}
+
+sub new {
+ my $class = shift;
+ my $filename = shift;
+ local %_ = @_;
+ my $self = bless { filename => $filename }, $class;
+ my $v;
+ my $err;
+
+ if (defined($v = delete $_{error})) {
+ if (ref($v) eq 'CODE') {
+ $self->{error} = $v;
+ } else {
+ carp "error must refer to a CODE";
+ ++$err;
+ }
+ } else {
+ $self->{error} = \&deferror;
+ }
+
+ if (defined($v = delete $_{debug})) {
+ if (ref($v) eq 'CODE') {
+ $self->{debug} = $v;
+ } else {
+ carp "debug must refer to a CODE";
+ ++$err;
+ }
+ }
+
+ if (defined($v = delete $_{ci})) {
+ $self->{ci} = $v;
+ }
+
+ if (defined($v = delete $_{parameters})) {
+ if (ref($v) eq 'HASH') {
+ $self->{parameters} = $v;
+ } else {
+ carp "parameters must refer to a HASH";
+ ++$err;
+ }
+ }
+
+ if (defined($v = delete $_{cachefile})) {
+ $self->{cachefile} = $v;
+ }
+
+ if (defined($v = delete $_{cache})) {
+ unless (exists($self->{cachefile})) {
+ $v = $self->{filename};
+ $v =~ s/\.(conf|cnf|cfg)$//;
+ unless ($v =~ s#(.+/)?(.+)#$1.$2#) {
+ $v = ".$v";
+ }
+ $self->{cachefile} = "$v.cache";
+ }
+ }
+
+ if (defined($v = delete $_{rw})) {
+ $self->{rw} = $v;
+ }
+
+ if (keys(%_)) {
+ foreach my $k (keys %_) {
+ carp "unknown parameter $k"
+ }
+ ++$err;
+ }
+ return undef if $err;
+ return $self;
+}
+
+sub DESTROY {
+ my $self = shift;
+ $self->writecache();
+}
+
+sub writecache {
+ my $self = shift;
+ return unless exists $self->{cachefile};
+ return unless exists $self->{conf};
+ return unless $self->{updated};
+ &{$self->{debug}}("storing cache file $self->{cachefile}")
+ if exists $self->{debug};
+ store $self->{conf}, $self->{cachefile};
+}
+
+sub parse_section {
+ my ($self, $conf, $input) = @_;
+ my $ref = $conf;
+ my $quote;
+ my $rootname;
+ my $kw = $self->{parameters} if exists $self->{parameters};
+ while ($input ne '') {
+ my $name;
+ if (!defined($quote)) {
+ if ($input =~ /^"(.*)/) {
+ $quote = '';
+ $input = $1;
+ } elsif ($input =~ /^(.+?)(?:\s+|")(.*)/) {
+ $name = $1;
+ $input = $2;
+ } else {
+ $name = $input;
+ $input = '';
+ }
+ } else {
+ if ($input =~ /^([^\\"]*)\\(.)(.*)/) {
+ $quote .= $1 . $2;
+ $input = $3;
+ } elsif ($input =~ /^([^\\"]*)"\s*(.*)/) {
+ $name = $quote . $1;
+ $input = $2;
+ $quote = undef;
+ } else {
+ croak "unparsable input $input";
+ }
+ }
+
+ if (defined($name)) {
+ $rootname = $name unless defined $rootname;
+ $ref->{$name} = {} unless ref($ref->{$name}) eq 'HASH';
+ $ref = $ref->{$name};
+
+ if (defined($kw)
+ and ref($kw) eq 'HASH' and exists($kw->{$name}{section})) {
+ $kw = $kw->{$name}{section};
+ }
+
+ $name = undef;
+ }
+ }
+ return ($ref, $rootname, $kw);
+}
+
+sub check_mandatory {
+ my ($self, $section, $kw, $loc, $s) = @_;
+ my $err = 0;
+ while (my ($k, $d) = each %{$kw}) {
+ if (ref($d) eq 'HASH'
+ and $d->{mandatory}
+ and !exists($section->{$k})) {
+ if (exists($d->{section})) {
+ if ($s) {
+ $self->{error}("$loc: mandatory section [$k] not present");
+ ++$err;
+ }
+ } else {
+ $self->{error}("$loc: mandatory variable \"$k\" not set");
+ ++$err;
+ }
+ }
+ }
+ return $err;
+}
+
+sub readconfig {
+ my $self = shift;
+ my $file = shift;
+ my $conf = shift;
+
+ &{$self->{debug}}("reading file $file") if exists $self->{debug};
+ open(my $fd, "<", $file)
+ or do {
+ $self->{error}("can't open configuration file $file: $!");
+ return 1;
+ };
+
+ my $line;
+ my $err;
+ my $section = $conf;
+ my $kw = $self->{parameters};
+ my $include = 0;
+ my $rootname;
+
+ while (<$fd>) {
+ ++$line;
+ chomp;
+ if (/\\$/) {
+ chop;
+ $_ .= <$fd>;
+ redo;
+ }
+
+ s/^\s+//;
+ s/\s+$//;
+ s/#.*//;
+ next if ($_ eq "");
+
+ if (/^\[(.+?)\]$/) {
+ $include = 0;
+ my $arg = $1;
+ $arg =~ s/^\s+//;
+ $arg =~ s/\s+$//;
+ if ($arg eq 'include') {
+ $include = 1;
+ } else {
+ ($section, $rootname, $kw) = $self->parse_section($conf, $1);
+ $self->{error}("$file:$line: unknown section")
+ if (exists($self->{parameters}) and !defined($kw));
+ }
+ } elsif (/([\w_-]+)\s*=\s*(.*)/) {
+ my ($k, $v) = ($1, $2);
+ $k = lc($k) if $self->{ci};
+
+ if ($include) {
+ if ($k eq 'path') {
+ $err += $self->readconfig($v, $conf, include => 1);
+ } elsif ($k eq 'pathopt') {
+ $err += $self->readconfig($v, $conf, include => 1)
+ if -f $v;
+ } elsif ($k eq 'glob') {
+ foreach my $file (bsd_glob($v, 0)) {
+ $err += $self->readconfig($file, $conf, include => 1);
+ }
+ } else {
+ $self->{error}("$file:$line: unknown keyword");
+ ++$err;
+ }
+ next;
+ }
+
+ if (defined($kw)) {
+ my $x = $kw->{$k};
+ $x = $kw->{'*'} unless defined $x;
+ if (!defined($x)) {
+ $self->{error}("$file:$line: unknown keyword $k");
+ ++$err;
+ next;
+ } elsif (ref($x) eq 'HASH') {
+ my $errstr;
+ my $prev_val = $section->{$k} if exists $section->{$k};
+ if (exists($x->{re})) {
+ if ($v !~ /$x->{re}/) {
+ $self->{error}("$file:$line: invalid value for $k");
+ ++$err;
+ next;
+ }
+ if (exists($x->{check})
+ and defined($errstr = &{$x->{check}}(\$v, $prev_val))) {
+ $self->{error}("$file:$line: $errstr");
+ ++$err;
+ next;
+ }
+ } elsif (exists($x->{check})) {
+ if (defined($errstr = &{$x->{check}}(\$v, $prev_val))) {
+ $self->{error}("$file:$line: $errstr");
+ ++$err;
+ next;
+ }
+ }
+ }
+ }
+
+ $section->{$k} = $v;
+ } else {
+ $self->{error}("$file:$line: malformed line");
+ ++$err;
+ next;
+ }
+ }
+ close $fd;
+ return $err;
+}
+
+sub file_up_to_date {
+ my ($self, $file) = @_;
+ my $st_conf = stat($self->{filename}) or return 1;
+ my $st_file = stat($file)
+ or carp "can't stat $file: $!";
+ return $st_conf->mtime <= $st_file->mtime;
+}
+
+sub parse {
+ my ($self) = @_;
+ my %conf;
+
+ if (exists($self->{cachefile}) and -f $self->{cachefile}) {
+ if ($self->file_up_to_date($self->{cachefile})) {
+ my $ref;
+ &{$self->{debug}}("reading from cache file $self->{cachefile}")
+ if exists $self->{debug};
+ eval { $ref = retrieve($self->{cachefile}); };
+ if (defined($ref)) {
+ $self->{conf} = $ref;
+ $self->{updated} = $self->{rw};
+ return 1;
+ } elsif ($@) {
+ $self->{error}("warning: unable to load configuration cache: $@");
+ }
+ }
+ unlink $self->{cachefile};
+ }
+
+ &{$self->{debug}}("parsing $self->{filename}") if exists $self->{debug};
+ my $err = $self->readconfig($self->{filename}, \%conf);
+ if ($err == 0) {
+ $self->{conf} = \%conf ;
+ $self->{updated} = 1;
+ }
+ return !$err;
+}
+
+sub get {
+ my $self = shift;
+
+ return undef unless exists $self->{conf};
+ my $ref = $self->{conf};
+ for (@_) {
+ return undef unless exists $ref->{$_};
+ $ref = $ref->{$_};
+ }
+ return $ref;
+}
+
+sub isset {
+ my $self = shift;
+ return defined $self->get(@_);
+}
+
+sub issection {
+ my $self = shift;
+ my $ref = $self->get(@_);
+ return defined($ref) and ref($ref) eq 'HASH';
+}
+
+sub isscalar {
+ my $self = shift;
+ my $ref = $self->get(@_);
+ return defined($ref) and ref($ref) ne 'HASH';
+}
+
+sub set {
+ my $self = shift;
+ $self->{conf} = {} unless exists $self->{conf};
+ my $ref = $self->{conf};
+
+ while ($#_ > 1) {
+ my $arg = shift;
+ $ref->{$arg} = {} unless exists $ref->{$arg};
+ $ref = $ref->{$arg};
+ }
+ $ref->{$_[0]} = $_[1];
+ $self->{updated} = $self->{rw};
+}
+
+sub unset {
+ my $self = shift;
+ return unless exists $self->{conf};
+ my $ref = $self->{conf};
+ my @path;
+
+ for (@_) {
+ return unless exists $ref->{$_};
+ push @path, [ $ref, $_ ];
+ $ref = $ref->{$_};
+ }
+
+ while (1) {
+ my $loc = pop @path;
+ delete ${$loc->[0]}{$loc->[1]};
+ last unless (defined($loc) and keys(%{$loc->[0]}) == 0);
+ }
+ $self->{updated} = $self->{rw};
+}
+
+#sub each {
+# my $self = shift;
+# return @{[ each %{$self->{conf}} ]};
+#}
+
+sub _foreach {
+ my ($self, $domain, $aref, $cb, $sort) = @_;
+ my @keys = keys(%{$aref});
+ foreach my $k (defined($sort) ? sort $sort @keys : @keys) {
+ my $v = $aref->{$k};
+ if (ref($v) eq 'HASH') {
+ push @{$domain}, $k;
+ $self->_foreach($domain, $v, $cb, $sort);
+ pop @{$domain};
+ } else {
+ &{$cb}($k, $v, @{$domain});
+ }
+ }
+}
+
+sub foreach {
+ my $self = shift;
+ my $cb = shift;
+
+ local %_ = @_;
+ my $sort = delete $_{sort};
+
+ if (defined($sort) && ref($sort) ne 'CODE') {
+ if ($sort == 1) {
+ $sort = sub { $a cmp $b };
+ } else {
+ carp "sort must refer to a CODE";
+ return;
+ }
+ }
+ if (keys(%_)) {
+ foreach my $k (keys %_) {
+ carp "unknown parameter $k";
+ }
+ return;
+ }
+
+ $self->_foreach([], $self->{conf}, $cb, $sort);
+}
+
+sub flatten {
+ my $self = shift;
+ my @dump;
+ $self->foreach(sub {
+ my $k = shift;
+ my $v = shift;
+ push @_, $k;
+ push @dump, [ join('.', @_), $v ];
+ },
+ sort => 1);
+ return @dump;
+}
diff --git a/lib/Makefile.am b/lib/Makefile.am
deleted file mode 100644
index 20a50e8..0000000
--- a/lib/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS=beam
diff --git a/lib/beam/.gitignore b/lib/beam/.gitignore
deleted file mode 100644
index 5621a6e..0000000
--- a/lib/beam/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-common.sh
diff --git a/lib/beam/Makefile.am b/lib/beam/Makefile.am
deleted file mode 100644
index 81385ad..0000000
--- a/lib/beam/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-# 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/>.
-
-libbackupdir=$(libdir)/beam
-libbackup_SCRIPTS=\
- common.sh\
- s3.sh\
- fs.sh\
- ldap.sh\
- mysql.sh\
- postgres.sh
-EXTRA_DIST=\
- common.in\
- s3.sh\
- fs.sh\
- ldap.sh\
- mysql.sh\
- postgres.sh
-DISTCLEANFILES=common.sh
-include $(top_srcdir)/Make.rules
diff --git a/lib/beam/common.in b/lib/beam/common.in
deleted file mode 100644
index bc724c7..0000000
--- a/lib/beam/common.in
+++ /dev/null
@@ -1,253 +0,0 @@
-#! /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/>.
-
-# Force C locale
-LC_ALL=C
-export LC_ALL
-
-openlog_hook=
-prologue_hook=
-epilogue_hook=
-
-# User configuration variables
-backup_tar_options=
-backup_suffix=
-backup_archive_dir=
-backup_snapshot_dir=
-backup_verbose=
-backup_logfile="/var/log/backup"
-backup_pidfile="/var/run/beam.pid"
-backup_tmp_dir=/tmp
-
-error() {
- echo >&2 $0: $*
-}
-
-logit() {
- echo `date`: $*
-}
-
-abend() {
- ec=$1
- shift
- error $@
- exit $ec
-}
-
-beam_lock() {
- 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"
- fi
- abend 1 "another beam process (pid $pid) is still running; exiting"
- fi
- echo $$ > $backup_pidfile || exit 1
- epilogue_hook="$epilogue_hook beam_unlock"
-}
-
-beam_unlock() {
- rm -f $backup_pidfile
-}
-
-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
-}
-
-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
-
- 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
-$type"
- else
- error "$libdir/${type}.sh not found"
- delayed_exit=1
- fi
-
- ${type}_check $item || delayed_exit=1
- done
-
- test -n "$delayed_exit" && abend 1 "aborting"
-
- tar_suffix=${backup_suffix:-.tar}
-
- 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
-}
-
-beam_exec() {
- if [ -z "$beam_rsh" ]; then
- set -- $(echo "$@" | sed 's/\\\\\([bcfnrtv0]\)/\\\1/g')
- "$@"
- else
- set -- $(echo "$@" | sed 's/\\\\\([bcfnrtv0]\)/\\\1/g;s/[]\[\\\*]/\\&/g')
- $beam_rsh "$@"
- fi
-}
-
-runhook() {
- local hook_list
-
- eval hook_list=\$$1
- for hook in $hook_list
- do
- $hook
- done
-}
-
-print_version() {
- name=$(basename $0)
- cat <<EOF
-$name (@PACKAGE_NAME@) @PACKAGE_VERSION@
-Copyright (C) 2012-2014 Sergey Poznyakoff
-License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
-This is free software: you are free to change and redistribute it.
-There is NO WARRANTY, to the extent permitted by law.
-EOF
- exit 0
-}
-
-wtf() {
- l=$(echo "${1#beam-}"|sed "s|.|.|g")
- s=$(echo " " | sed "s|$l|${1#beam-}|")
- shift
- echo " $s $@"
-}
-
-dry_mail() {
- echo "============================================================="
- cat -
- echo "============================================================="
-}
-
-# mail_report FILE
-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\""
- 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
-To: $backup_notify_email
-Subject: $backup_report_subject
-X-Beam-Items: $backup_items
-X-Beam-Round: $round
-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
-}
-
-beam_logrotate() {
- 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
-$backup_logfile {
-$backup_logrotate_conf
-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
-}
diff --git a/lib/beam/fs.sh b/lib/beam/fs.sh
deleted file mode 100755
index 015082b..0000000
--- a/lib/beam/fs.sh
+++ /dev/null
@@ -1,148 +0,0 @@
-#! /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/>.
-
-# Configuration keywords:
-#
-# item_type=fs [mandatory]
-# item_dir=STRING [mandatory]
-# item_files=STRING [mandatory]
-# item_exclude=STRING [optional]
-# item_exclude_from=STRING [optional]
-# item_tar_options=STRING [optional internal]
-#
-
-# initdb item
-# Initializes snapshot for the given basename.
-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
- 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
-}
-
-# fs_check item
-fs_check() {
- local rc=0 root 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
-}
-
-# fs_list item prefix
-fs_list() {
- local dir files lsf=
-
- eval dir=\$${1}_dir files=\$${1}_files
- for file in $files
- do
- if [ -d "$dir/$file" ]; then
- lsf="$lsf $file/"
- else
- lsf="$lsf $file"
- fi
- done
- echo "${2}Files and directories in $dir:$lsf"
-}
-
-# fs_backup item
-fs_backup() {
- local basename text root files exclude addopts s e
-
- basename=$1-$week-$round-$level
- eval text=\$${1}_text
- eval root=\$${1}_dir
- eval files=\$${1}_files
- eval addopts=\$${1}_tar_options
-
- eval exclude=\$${1}_exclude
- for e in $exclude
- do
- eval s="$e"
- addopts="$addopts --exclude=$s"
- done
-
- eval exclude=\$${1}_exclude_from
- for e in $exclude
- do
- addopts="$addopts --exclude-from=$e"
- done
-
- test -z "$root" && abend 1 "${1}_dir not set"
- test -z "$files" && abend 1 "${1}_files not set"
- test -z "$text" && text="$1"
- initdb $1
- logit "backing up $text ($basename.$tar_suffix)"
- $dry_run tar $verbose $taroptions $addopts \
- -f $backup_archive_dir/$basename.$tar_suffix \
- --listed=$backup_snapshot_dir/$basename.db \
- -C $root $files
- tarcode $?
-}
-
-# fs_restore item
-fs_restore() {
- local i text root files tarcommand
-
- eval text=\$${1}_text
- eval root=\$${1}_dir
- eval files=\$${1}_files
-
- test -z "$root" && abend 1 "${1}_dir not set"
- test -z "$files" && abend 1 "${1}_files not set"
- test -z "$text" && text="$1"
-
- tarcommand="tar $verbose $taroptions -C $root --listed-incremental=/dev/null -f"
-
- logit "restoring $text"
- logit "restoring from level 0 backup"
-
- $dry_run $tarcommand $backup_archive_dir/$1-$week-0-0.$tar_suffix
- tarcode $?
-
- for i in $(seq 1 $level)
- do
- logit "restoring from the $round/$i backup"
- $dry_run $tarcommand $backup_archive_dir/$1-$week-$round-$i.$tar_suffix
- tarcode $?
- done
- logit "finished restoring $text"
-}
-
diff --git a/lib/beam/ldap.sh b/lib/beam/ldap.sh
deleted file mode 100755
index 40b9a4b..0000000
--- a/lib/beam/ldap.sh
+++ /dev/null
@@ -1,164 +0,0 @@
-#! /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/>.
-
-# Configuration keywords:
-#
-# item_type=ldap [mandatory]
-# item_database_directory=string [mandatory]
-# item_database_number=n [optional *]
-# item_database_suffix=suf [optional *]
-# item_uri=str [optional]
-# item_user=name [optional]
-# item_slapcat_options=string [optional internal]
-# item_slapadd_options=string [optional internal]
-#
-# * - mutually exclusive keywords.
-
-
-# ldap_check item
-ldap_check() {
- local rc=0 dbno dbsuf dbdir
- eval dbno=\$${1}_database_number \
- dbsuf=\$${1}_database_suffix \
- dbdir=\$${1}_database_directory
- if test -n "$dbno" && test -n "$dbsuf"; then
- error "$1: both ${1}_database_number and ${1}_database_suffix are set"
- rc=1
- fi
- if test -z "$dbdir"; then
- error "${1}_database_directory not configured"
- rc=1
- fi
- if ! test -d "$dbdir"; then
- error "LDAP database directory $dbdir does not exist"
- error "(set by ${1}_database_directory)"
- fi
- return $rc
-}
-
-# ldap_list item prefix
-ldap_list() {
- local dbid
-
- eval dbid=\$${1}_database_number
- if [ -n "$dbid" ]; then
- dbid=" number $dbid"
- else
- eval dbid=\$${1}_database_suffix
- if [ -n "$dbid" ]; then
- dbid=" suffixed with $dbid"
- fi
- fi
-
- echo "${2}LDAP database"$dbid
-}
-
-# ldap_backup item
-ldap_backup() {
- local options dbno dbsuf uri
-
- logit "backing up LDAP database $1"
-
- eval options=\$${1}_slapcat_options \
- dbno=\$${1}_database_number \
- dbsuf=\$${1}_database_suffix
-
- if [ -n "$dbno" ]; then
- options="$options -n$dbnum"
- elif [ -n "$dbsuf" ]; then
- options="$options -b$slapcat"
- fi
-
- eval uri=\"\$${1}_uri\"
- if [ -n "$uri" ]; then
- options="$options -H\"$uri\""
- fi
-
- if [ -z "$dry_run" ]; then
- slapcat $options > $backup_snapshot_dir/$1-$week-$round-$level
- else
- echo "slapcat $options > $backup_snapshot_dir/$1-$week-$round-$level"
- fi
-
- if [ $? -ne 0 ]; then
- tarerror=$((tarerror + 1))
- logit "failed"
- else
- logit "creating $1-$week-$round-$level.$tar_suffix"
- $dry_run tar $verbose $taroptions \
- -f $backup_archive_dir/$1-$week-$round-$level.$tar_suffix \
- -C $backup_snapshot_dir $1-$week-$round-$level
- tarcode $?
- $dry_run rm $backup_snapshot_dir/$1-$week-$round-$level
- fi
-}
-
-# ldap_restore item
-ldap_restore() {
- local options dbno dbsuf dbdir u user
-
- logit "extracting LDAP database dump $1"
-
- eval options=\$${1}_slapadd_options dbno=\$${1}_database_number \
- dbsuf=\$${1}_database_suffix dbdir=\$${1}_database_directory \
- user=\$${1}_user
-
- if test -z "$dbdir"; then
- error "${1}_database_directory not configured"
- tarerror=$((tarerror + 1))
- return
- fi
- if [ -n "$dbno" ]; then
- options="$options -n$dbnum"
- elif [ -n "$dbsuf" ]; then
- options="$options -b$slapcat"
- fi
-
- u=$(umask)
- trap "umask $u" 1 2 3 13 15
- umask 077
- $dry_run tar $verbose $taroptions \
- -f $backup_archive_dir/$1-$week-$round-$level.$tar_suffix
- e=$?
- tarcode $e
- if [ $e -eq 0 ]; then
- prevdbtar=$backup_snapshot_dir/ldap-$1-$(date +%Y%m%dT%H%M%S).tar
- logit "archiving the previous database contents to $prevdbtar"
- $dry_run tar $verbose -c -f $prevdbtar $dbdir
- e=$?
- tarcode $e
- umask $u
- if [ $e -ne 0 ]; then
- error "Failed to backup the prior database contents to $prevdbtar"
- return
- fi
- logit "removing old database files in $dbdir"
- $dry_run rm $dbdir/*
- logit "restoring database $1 from the dump"
- if test -n "$user"; then
- su $user -c "$dry_run slapadd $options $verbose -l $1-$week-$round-$level"
- su $user -c "$dry_run slapindex"
- else
- $dry_run slapadd $options $verbose -l $1-$week-$round-$level
- $dry_run slapindex
- fi
- # FIXME: error checking
- $dry_run rm $1-$week-$round-$level
- fi
- umask $u
- trap - 1 2 3 13 15
-}
diff --git a/lib/beam/mysql.sh b/lib/beam/mysql.sh
deleted file mode 100755
index e8ec32c..0000000
--- a/lib/beam/mysql.sh
+++ /dev/null
@@ -1,175 +0,0 @@
-#! /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/>.
-
-# Configuration keywords:
-#
-# item_type=mysql [mandatory]
-# item_database=STRING [optional]
-# item_defaults_file=STRING [optional]
-# item_alldb=single|monolithic|split|individual [optional]
-#
-
-# mysql_check item
-mysql_check() {
- return 0
-}
-
-# mysql_list item prefix
-mysql_list() {
- local database
-
- eval database=\$${1}_database
- if [ -z "$database" ]; then
- echo "${2}all MySQL databases"
- else
- echo "${2}MySQL database $database"
- fi
-}
-
-# dump_mysql_db cmd stem
-dump_mysql_db() {
- if [ -z "$dry_run" ]; then
- $1 $db > $backup_tmp_dir/$2-$week-$round-$level
- else
- echo "$1 $db > $backup_tmp_dir/$2-$week-$round-$level"
- fi
-
- if [ $? -ne 0 ]; then
- tarerror=$((tarerror + 1))
- logit "failed"
- else
- logit "creating $2-$week-$round-$level.$tar_suffix"
- $dry_run tar $verbose $taroptions \
- -f $backup_archive_dir/$2-$week-$round-$level.$tar_suffix \
- -C $backup_tmp_dir $2-$week-$round-$level
- tarcode $?
- $dry_run rm $backup_tmp_dir/$2-$week-$round-$level
- fi
-}
-
-restore_mysql_db() {
- local u
-
- logit "restoring MySQL database $1"
- u=$(umask)
- trap "umask $u" 1 2 3 13 15
- umask 077
- $dry_run tar $verbose $taroptions \
- -f $backup_archive_dir/$1-$week-$round-$level.$tar_suffix
- e=$?
- tarcode $e
- if [ $e -eq 0 ]; then
- logit "restoring database from the dump"
- # Stupid lossage: cannot give -A option here, because with it mysql
- # refuses to understand defaults-file.
- cmd="mysql"
- eval defaults_file=\$${1}_defaults_file
- if [ -n "$defaults_file" ]; then
- cmd="$cmd --defaults-file=$defaults_file"
- fi
- if [ -n "$dry_run" ]; then
- echo "$cmd < $1-$week-$round-$level"
- elif [ -r $1-$week-$round-$level ]; then
- $cmd < $1-$week-$round-$level > db-$1.log
- if grep ERROR db-$1.log >/dev/null; then
- error "errors occurred during restore; see db-$1.log for details"
- error "dump preserved in file $1-$week-$round-$level"
- tarerror=$((tarerror + 1))
- else
- rm $1-$week-$round-$level
- fi
- fi
- fi
- umask $u
- trap - 1 2 3 13 15
-}
-
-# mysql_backup item
-mysql_backup() {
- local creds cmd database alldb db stem
-
- eval database=\$${1}_database
- if [ -z "$database" ]; then
- logit "backing up all MySQL databases"
- else
- logit "backing up MySQL database $database"
- fi
- cmd="mysqldump"
- eval defaults_file=\$${1}_defaults_file
- if [ -n "$defaults_file" ]; then
- creds="--defaults-file=$defaults_file"
- cmd="$cmd $creds"
- fi
- cmd="$cmd --add-drop-database"
- cmd="$cmd --single-transaction"
-
- if test -z "$database"; then
- eval alldb=\$${1}_alldb
- case $alldb in
- single|monolithic)
- cmd="$cmd --all-databases";;
- split|individual)
- alldb=split
- cmd="$cmd --databases"
- database=$(mysql $creds -e "show databases" -B --skip-column-names);;
- "") cmd="$cmd --all-databases";;
- *) error "unknown value: ${1}_alldb=$alldb, assuming 'single'"
- cmd="$cmd --all-databases";;
- esac
- else
- cmd="$cmd --databases"
- fi
-
- if [ -z "$database" ]; then
- dump_mysql_db "$cmd" "$1"
- else
- for db in $database
- do
- if [ "$alldb" = split ]; then
- stem=$1-$db
- logit "dumping $db"
- else
- stem=$1
- fi
- dump_mysql_db "$cmd" "$stem"
- done
- fi
-}
-
-mysql_restore() {
- local database dbname remote
-
- eval database=\$${1}_database
- if test -z "$database"; then
- eval alldb=\$${1}_alldb
- case $alldb in
- split|individual)
- beam_exec find $backup_local_archive_dir \
- -name $1-'*'-$week-$round-$level.$tar_suffix \
- -printf '%f\\n' | \
- while read file
- do
- restore_mysql_db $(expr "$file" : "$1-\(.[^-]*\)-.*")
- done
- ;;
- *) restore_mysql_db $1
- esac
- else
- restore_mysql_db $database
- fi
-}
-
diff --git a/lib/beam/postgres.sh b/lib/beam/postgres.sh
deleted file mode 100755
index 3938c1a..0000000
--- a/lib/beam/postgres.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#! /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/>.
-
-# Configuration keywords:
-#
-# item_type=postgres [mandatory]
-# item_database=STRING [mandatory]
-
-# postgres_check item
-postgres_check() {
- local database
-
- eval database=\$${1}_database
- test -z "$database" && error "${1}_database not set" && return 1
- return 0
-}
-
-# postgres_list item prefix
-postgres_list() {
- local database
-
- eval database=\$${1}_database
- echo "${2}PostgreSQL database $database"
-}
-
-# postgres_backup item
-postgres_backup() {
- local database
-
- eval database=\$${1}_database
- logit "backing up PostgreSQL database $database"
- test -z "$database" && abend 1 "${1}_database not set"
- if [ -z "$dry_run" ]; then
- su postgres -c "pg_dump $verbose $database" > $backup_tmp_dir/$1-$week-$round-$level
- else
- echo "su postgres -c \"pg_dump $verbose $database\" > $backup_tmp_dir/$1-$week-$round-$level"
- fi
-
- if [ $? -ne 0 ]; then
- tarerror=$((tarerror + 1))
- logit "failed"
- else
- logit "creating $1-$week-$round-$level.$tar_suffix"
- $dry_run tar $verbose $taroptions \
- -f $backup_archive_dir/$1-$week-$round-$level.$tar_suffix \
- -C $backup_tmp_dir $1-$week-$round-$level
- tarcode $?
- $dry_run rm $backup_tmp_dir/$1-$week-$round-$level
- fi
-}
-
-postgres_restore() {
- local u database
-
- eval database=\$${1}_database
- logit "restoring PostgreSQL database $database"
- u=$(umask)
- trap "umask $u" 1 2 3 13 15
- umask 077
- $dry_run tar $verbose $taroptions \
- -f $backup_archive_dir/$1-$week-$round-$level.$tar_suffix
- e=$?
- tarcode $e
- if [ $e -eq 0 ]; then
- logit "restoring database from the dump"
- if [ -n "$dry_run" ]; then
- cat <<-EOT
- su postgres -c "dropdb $database"
- su postgres -c "createdb $database"
- su postgres -c "psql -d $database -f $1-$week-$round-$level"
- rm $1-$week-$round-$level
-EOT
- elif [ -r $1-$week-$round-$level ]; then
- su postgres -c "dropdb $database"
- su postgres -c "createdb $database"
- su postgres -c "psql -d $database -f $1-$week-$round-$level" > db-$1.log
- if grep ERROR db-$1.log >/dev/null; then
- error "errors occurred during restore; see db-$1.log for details"
- error "dump preserved in file $1-$week-$round-$level"
- tarerror=$((tarerror + 1))
- else
- rm $1-$week-$round-$level
- fi
- fi
- fi
- umask $u
- trap - 1 2 3 13 15
-}
diff --git a/lib/beam/s3.sh b/lib/beam/s3.sh
deleted file mode 100644
index 7b6ad91..0000000
--- a/lib/beam/s3.sh
+++ /dev/null
@@ -1,105 +0,0 @@
-#! /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/>.
-
-# The configuration variable "backup_bucket_name" must contain the name
-# of the s3 bucket to use.
-
-# Raw bucket is mounted to /mnt/s3backer
-test -z "$backup_mp_s3backer" && backup_mp_s3backer=/mnt/s3backer
-# The actual file system is mounted to /mnt/s3
-test -z "$backup_mp" && backup_mp_s3=/mnt/s3
-
-s3_getmpoint()
-{
- case $1 in
-# Sample mount output, split into several lines:
-# a) With --vhost:
-# http://BUCKETNAME.s3.amazonaws.com/ on /mnt/s3backer type fuse.s3backer
-# (rw,nosuid,nodev,allow_other,default_permissions)
-# b) Without --vhost:
-# http://s3.amazonaws.com/BUCKETNAME/ on /mnt/s3backer type fuse.s3backer
-# (rw,nosuid,nodev,allow_other,default_permissions)
- backer)
- mount -tfuse.s3backer |
- awk '/https?:\/\/.*'$backup_bucket_name'/ { print $3 }';;
- s3)
- s=$(mount | grep "^${backup_mp_s3backer}/file" | awk '{ print $3 }')
- if [ -z "$s" ]; then
- # Some kernels print device name instead of the actual mount file:
- s=$(mount | grep "^/dev/loop[0-9] on ${backup_mp_s3}" |
- awk '{ print $3 }')
- fi
- echo $s;;
- *)
- abent 1 "invalid usage of getmpoint"
- esac
-}
-
-# This variable is populated by s3_mount and is used by s3_unmount to unmount
-# s3-backed file system.
-umount_list=""
-
-s3_mount() {
- # Make sure both mountpoints exist
- test -d $backup_mp_s3backer || mkdir $backup_mp_s3backer
- test -d $backup_mp_s3 || mkdir $backup_mp_s3
-
- set -- $(s3_getmpoint backer)
- if test -z "$1"; then
- $dry_run s3backer $backup_s3backer_options \
- $backup_bucket_name $backup_mp_s3backer ||
- abend 1 "unable to mount $backup_bucket_name"
- umount_list="$backup_mp_s3backer"
- else
- backup_mp_s3backer=$1
- fi
- set -- $(s3_getmpoint s3)
- if test -z "$1"; then
- case $(basename $0) in
- beam-restore|restore) mountopt=",ro";;
- beam-backup|backup) mountopt=",rw";;
- beam-s3) ;;
- *) error "called as $0: assuming default mount options"
- esac
- test -n "$backup_s3_mount_options" &&
- mountopt="$mountopt,$backup_s3_mount_options"
- # NOTE: For ext4 add the journal_async_commit option.
- $dry_run mount -oloop$mountopt \
- $backup_mp_s3backer/file $backup_mp_s3 ||
- abend 1 "unable to mount $backup_mp_s3backer/file"
- umount_list="$backup_mp_s3 $umount_list"
- else
- backup_mp_s3=$1
- fi
- epilogue_hook="s3_unmount $epilogue_hook"
-}
-
-s3_unmount()
-{
- if test "$1" = "--force"; then
- for id in s3 backer
- do
- mpoint=$(s3_getmpoint $id)
- test -n "$mpoint" && $dry_run umount $mpoint
- done
- else
- for mpoint in $umount_list
- do
- test -n "$mpoint" && $dry_run umount $mpoint
- done
- fi
-}
diff --git a/list.in b/list.in
deleted file mode 100644
index 4198d3c..0000000
--- a/list.in
+++ /dev/null
@@ -1,101 +0,0 @@
-#! /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/>.
-
-libdir=@LIBDIR@/beam
-set -e
-. $libdir/common.sh
-set +e
-
-if [ "$1" = "--wtf" ]; then
- wtf $(basename $0) list what is included in backups
- exit 0
-fi
-
-help() {
- cat <<EOF
-usage: $0
-list what is included in backups
-
-OPTIONS:
-
- -l, --number produce a numbered list
-
- -h, --help produce this help list
- -V, --version print program version
-
-Report bugs to <@PACKAGE_BUGREPORT@>
-EOF
- exit 0
-}
-
-###########################################################
-# Main
-###########################################################
-
-numbered_list=
-while [ $# -ne 0 ]
-do
- case $1 in
- -l|--number) numbered_list=1;;
- -h|--help) help;;
- -V|--version) print_version;;
- *) echo >&2 "$0: unrecognized option $1"; exit 1;;
- esac
- shift
-done
-
-load_config
-
-if [ -z "$backup_items" ]; then
- echo "Nothing is being backed up"
-fi
-
-delayed_exit=
-loaded_types=
-if test -n "$numbered_list"; then
- n=0
-fi
-prefix=
-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
-$type"
- else
- error "$libdir/${type}.sh not found"
- delayed_exit=1
- fi
-
- if test -n "$numbered_list"; then
- n=$((n + 1))
- prefix="$n. "
- fi
- ${type}_list $item "$prefix" || delayed_exit=1
-done
-
-test -n "$delayed_exit" && abend 1 "aborting"
-
-exit 0
diff --git a/restore.in b/restore.in
deleted file mode 100644
index 8618e2d..0000000
--- a/restore.in
+++ /dev/null
@@ -1,165 +0,0 @@
-#! /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/>.
-
-libdir=@LIBDIR@/beam
-set -e
-. $libdir/common.sh
-set +e
-
-if [ "$1" = "--wtf" ]; then
- wtf $(basename $0) create a backup
- exit 0
-fi
-
-load_config
-taroptions="$backup_tar_options $backup_rsh_command"
-
-# Options
-root=/
-verbose=
-logfile=
-dry_run=
-listonly=
-confirm=1
-
-getyn() {
- echo -n "$0:" $* " [Y/n]? "
- read REPLY
- case $REPLY in
- ''|y*|Y*) REPLY=y;;
- *) REPLY=n;;
- esac
-}
-
-help() {
- cat <<EOT
-usage: restore [OPTIONS] [ITEM [ITEM...]]
-restores this system from a backup
-
-OPTIONS:
- -c, --confirm do not ask for confirmation; run straight into restoring
- -C, --directory DIR restore into directory DIR instead of $root
- -v, --verbose increase verbosity
- -n, --dry-run do nothing, print what would have been done
- -t, --list list archives, instead of extracting
- -l, --logfile FILE log to FILE
- -L, --level N set incremental dump level to stop at
- -R, --round N use archives from incremental round N
- -W, --week N use archives from week N
- -h, --help produce this help list
-
-Valid ITEMs are: $backup_items
-
-Report bugs to <@PACKAGE_BUGREPORT@>
-EOT
- exit 0
-}
-
-while [ $# -ne 0 ]
-do
- case $1 in
- -C|--directory) shift; root=$1;;
- -c|--confirm) confirm=0;;
- -v|--verbose) verbose="$verbose -v";;
- -t|--list) listonly=1;;
- -l|--logfile) shift; logfile=$1; confirm=0;;
- -n|--dry-run) dry_run=echo;;
- -h|--help) help;;
- -V|--version) print_version;;
- -L|--level) shift; level=$1;;
- -R|--round) shift; round=$1;;
- -W|--week) shift; week=$1;;
- --) shift; break;;
- -*) echo >&2 "$0: unrecognized option $1"; exit 1;;
- *) break;;
- esac
- shift
-done
-
-if [ -z "$listonly" ]; then
- taroptions="$taroptions -x"
-else
- taroptions="$taroptions -t"
-fi
-
-# Collect items to be restored.
-items=$*
-
-test -z "$items" && items="$backup_items"
-
-if [ -n "$logfile" ]; then
- confirm=0
- exec >>$logfile
- exec 2>&1
-fi
-
-runhook prologue_hook
-trap "runhook epilogue_hook" EXIT INT QUIT TERM
-
-# Guess missing values
-if [ -z "$week" ]; then
- hour=$(date +%H)
- if [ $hour -gt 6 ]; then
- week=$(date +%U)
- else
- week=$(date -d yesterday +%U)
- fi
-fi
-
-if [ -z "$round" ]; then
- round=$(beam_exec find $backup_local_archive_dir \
- -regex '.*-'$week'-[0-9][0-9]*-[0-9][0-9]*\..*' \
- -printf '%f\\n' |
- sed 's/.*-'$week'-\([0-9][0-9]*\)-[0-9][0-9]*\..*/\1/' |
- sort +0 -1 |
- tail -1)
- test -z "$round" && abend 1 "cannot determine last round number"
-fi
-
-if [ -z "$level" ]; then
- level=$(beam_exec find $backup_local_archive_dir \
- -regex '.*-'$week-$round'-[0-9][0-9]*\..*' \
- -printf '%f\\n' |
- sed 's/.*-'$week-$round'-\([0-9][0-9]*\)\..*/\1/' |
- sort +0 -1 |
- tail -1)
- test -z "$level" && abend 1 "cannot determine last level number"
-fi
-
-echo "$0: target root directory $root"
-echo "$0: items to be restored: $items"
-echo "$0: restoring from week $week, round $round, level $level"
-
-if [ $confirm -ne 0 ]; then
- getyn "Do you wish to proceed"
- test $REPLY = "n" && exit 0
-fi
-
-logit "started"
-
-for item in $items
-do
- eval type=\$${item}_type
- ${type}_restore $item
-done
-
-trap - EXIT INT QUIT TERM
-runhook epilogue_hook
-
-logit "finished"
-
-
diff --git a/s3.in b/s3.in
deleted file mode 100644
index 3d9f2c5..0000000
--- a/s3.in
+++ /dev/null
@@ -1,85 +0,0 @@
-#! /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/>.
-
-set -e
-. @LIBDIR@/beam/common.sh
-set +e
-
-if [ "$1" = "--wtf" ]; then
- wtf $(basename $0) mount or unmount a backup s3 bucket
- exit 0
-fi
-
-test -z "$BEAM_CONFIG" && BEAM_CONFIG=@SYSCONFDIR@/beam.conf
-
-if [ ! -r $BEAM_CONFIG ]; then
- echo >&2 "$0: configuration file $BEAM_CONFIG is not found or is unreadable"
- exit 1
-fi
-
-. $BEAM_CONFIG
-. @LIBDIR@/beam/s3.sh
-
-if [ -z "$backup_bucket_name" ]; then
- echo >&2 "$0: backup_bucket_name is not defined (examine $BEAM_CONFIG)"
- exit 1
-fi
-
-help() {
- cat <<EOT
-usage: beam s3 [OPTIONS]
- or: beam s3 {mount|umount|status}
-$0 mounts or unmounts a backup s3 bucket, as configured in $BEAM_CONFIG
-
-OPTIONS:
- -V, --version print program version and exit
- -h, --help produce this help list
-
-Valid ITEMs are: $backup_items
-
-Report bugs to <@PACKAGE_BUGREPORT@>
-EOT
- exit 0
-}
-
-while [ $# -ne 0 ]
-do
- case $1 in
- -h|--help) help;;
- -V|--version) print_version;;
- *) break;;
- esac
-done
-
-case $1 in
- mount)
- s3_mount
- echo "$backup_bucket_name mounted under $backup_mp_s3";;
- umount|unmount)
- s3_unmount --force;;
- status)
- for id in s3 backer
- do
- mpoint=$(s3_getmpoint $id)
- if [ -n "$mpoint" ]; then
- echo "$id is mounted on $mpoint"
- fi
- done;;
-
- *) help
- exit 1;;
-esac
diff --git a/t/config.t b/t/config.t
new file mode 100644
index 0000000..d965844
--- /dev/null
+++ b/t/config.t
@@ -0,0 +1,12 @@
+# -*- perl -*-
+use lib 't';
+use strict;
+use App::Beam::Config;
+use Test;
+
+plan(tests => 2);
+
+my $cfg = new App::Beam::Config('t/f.conf');
+ok($cfg->parse() && 1);
+my $s = join " ", map { $_->[0] . "=" . $_->[1] } $cfg->flatten();
+ok($s, 'backend.foo.file=a core.retain-interval=10 core.tempdir=/tmp');
diff --git a/t/f.conf b/t/f.conf
new file mode 100644
index 0000000..17234a1
--- /dev/null
+++ b/t/f.conf
@@ -0,0 +1,6 @@
+[core]
+ retain-interval = 10
+ tempdir = /tmp
+[backend foo]
+ file = a
+

Return to:

Send suggestions and report system problems to the System administrator.