-#!/bin/sh
+#!/bin/bash
-# dvd-backup
+# backup
+#
+# Creates a single compressed archive.
-# Load configuration informations about device
-. /etc/sysconfig/cdrecord
-
-export MEDIA_DEV="/dev/dvd"
-export MEDIA_DIR="/media/dvd"
+if [ ! -f /etc/backup.conf ]; then
+ echo "Error: missing /etc/backup.conf configuration file."
+ exit 1
+fi
+# Read list of backup files/directories
source /etc/backup.conf
-export BKP_TMP_DIR
+# Set default value if not specified
+: ${BKP_DEST_DIR:="./"}
+
+# Default value
+ARCHIVE_LABEL="backup-data-amd64-`date '+%Y-%m-%d'`"
+
+# Exclude files list
+EXC_LIST="/tmp/exclude-sockets"
+
+print_usage()
+{
+ echo "$(basename $0) - Backup files/directories."
+ echo "Usage: $(basename $0) [-h] [--label "label"]"
+}
+
+if [ ${#} -gt 0 ]; then
+ if [ "x${1}" = "x-h" ]; then
+ print_usage
+ exit 0
+ fi
+ if [ "x${1}" = "x--label" ]; then
+ if [ $# -lt 2 ]; then
+ echo "Missing arguments for --label option"
+ print_usage
+ exit 1
+ fi
+
+ ARCHIVE_LABEL=${2}
+ shift
+ shift
+
+ if [ $# = 0 ]; then
+ echo "No directory to backup specified"
+ print_usage
+ exit 1
+ fi
+ else
+ echo "Unknown arguments: ${@}"
+ print_usage
+ exit 1
+ fi
+fi
+
+ARCHIVE_NAME=${BKP_DEST_DIR}/${ARCHIVE_LABEL}.tar.bz2
+
+echo "ARCHIVE_LABEL=$ARCHIVE_LABEL"
+
+# Finding sockets
+find ${DIRECTORIES} -type s > ${EXC_LIST} || exit 1
+
+# Archiving
+tar jcf ${ARCHIVE_NAME} ${BKP_FILES_LIST} \
+ --ignore-failed-read \
+ --label="${ARCHIVE_LABEL}" \
+ --exclude="*.sock" --exclude="*.lock" --exclude-from=${EXC_LIST} \
+ --absolute-names --totals
-media-write ${BKP_FILES_LIST}
+rm ${EXC_LIST}
exit $?
PREFIX="/usr/local"
BINDIR="${PREFIX}/bin"
SYSBINDIR="${PREFIX}/sbin"
+SYSCONFDIR="/etc"
BIN_UTILITIES="camera-download cd-erase cd-copy cgrep pstopdf distro-backup \
dos2unix dvd-ram-format fix-avi gztobz2 hv-backup hv-video-dvd \
mail-files mail-if-fail mail-statistics media-write pstopdf \
install -v ${SRCDIR}/${program} ${BINDIR}
done
+install -v -m 644 ${SRCDIR}/backup.conf ${SYSCONFDIR}
+
# Install fcrontab for rotatelogs
echo "# Rotate logs every day at 00:05" > /etc/fcron/fcron.d/rotatelogs
echo "&mail(false) 05 00 * * * ${BINDIR}/rotatelogs" >> /etc/fcron/fcron.d/rotatelogs