aboutsummaryrefslogtreecommitdiff
path: root/lib/backup/common.in
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backup/common.in')
-rw-r--r--lib/backup/common.in86
1 files changed, 86 insertions, 0 deletions
diff --git a/lib/backup/common.in b/lib/backup/common.in
new file mode 100644
index 0000000..ab80204
--- /dev/null
+++ b/lib/backup/common.in
@@ -0,0 +1,86 @@
+#! /bin/bash
+
+# Force C locale
+LC_ALL=C
+export LC_ALL
+
+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"
+
+error() {
+ echo >&2 $0: $*
+}
+
+logit() {
+ echo `date`: $*
+}
+
+abend() {
+ ec=$1
+ shift
+ error $@
+ exit $ec
+}
+
+tarcode() {
+ case $1 in
+ 0) echo "`date`: success";;
+ 1) echo "`date`: some files changed while being archived";;
+ 2) echo "`date`: fatal error occurred, but trying to continue anyway"
+ tarerror=$((tarerror + 1));;
+ *) echo "`date`: unexpected error code $1"
+ tarerror=$((tarerror + 1));
+ esac
+}
+
+load_config() {
+ local delayed_exit
+
+ test -z "$BACKUP_CONFIG" && BACKUP_CONFIG=@SYSCONFDIR@/backup.conf
+ if [ -r $BACKUP_CONFIG ]; then
+ . $BACKUP_CONFIG
+ else
+ abend 1 "configuration file $BACKUP_CONFIG does not exist or is unreadable"
+ fi
+
+ if [ -z "$backup_items" ]; then
+ abend 1 "backup_items not specified"
+ 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}
+}

Return to:

Send suggestions and report system problems to the System administrator.