Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion bin/tartarus
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ readonly VERSION="0.9.7"
# Tartarus provides a nice wrapper around basic Unix tools such as tar, find
# and curl to provide a seamless backup solution. Instead of relying on single
# usage backup scripts or complicated command lines, B<tartarus> reads its
# configuration from easily manageable configuration files. It can store
# configuration from easily managable configuration files. It can store
# gathered data in regular files, or upload the backup directly (on the fly)
# to an FTP server. For more specific usage scenarios, custom methods can also
# be defined within the config file.
Expand Down Expand Up @@ -126,11 +126,19 @@ cleanup() {
fi

if isEnabled "${CREATE_LVM_SNAPSHOT:-}" && [ -n "${SNAPDEV:-}" ]; then
if isEnabled "${KPARTX:-}"; then
umount $KPARTX_PARTITION || umount "$SNAPSHOT_DIR/$LVM_MOUNT_DIR"
kpartx -dv ${LVM_VOLUME_NAME}_snap
lvremove -f $SNAPDEV
else

# some filesystens (e.g. ntfs3g) appear as /dev/loop* in /proc/mounts,
# so unmounting the snapshot device might fail
umount $SNAPDEV || umount "$SNAPSHOT_DIR/$LVM_MOUNT_DIR"
lvremove -f $SNAPDEV
fi
fi

if [ "$ABORT" -eq "1" ]; then
debug "done"
fi
Expand Down Expand Up @@ -179,6 +187,7 @@ call() {
update_check() {
requireCommand curl awk || return
local VERSION_URL="http://wertarbyte.de/tartarus/upgrade-$VERSION"
VERSION_URL="${VERSION_URL}-deb"

local NEW_VERSION="$(curl --connect-timeout 15 -fs "$VERSION_URL")"
if [ "$?" -ne 0 ]; then
Expand Down Expand Up @@ -306,6 +315,20 @@ DIRECTORY=""
# store /proc or /sys.
STAY_IN_FILESYSTEM="no"
#
#=item KPARTX
#
# Kpartx can be used to set up device mappings for the partitions of any partitioned
# block device. If set to yes, kpartx will map the partitions so the filesystem can
# be accessed
#
# Once set, the specification of KPARTX_PARTITION becomes mandatory.
KPARTX=""
#
#=item KPARTX_PARTITION
#
# This is mandantory if KPARTX is set to yes. This is the name of the mapped partition.
KPARTX_PARTITION=""
#
#=item CREATE_LVM_SNAPSHOT
#
# If this is set to yes, Tartarus will try to freeze the content of the LVM
Expand Down Expand Up @@ -344,6 +367,7 @@ LVM_MOUNT_OPTIONS=""
# value defaults to "200m".
LVM_SNAPSHOT_SIZE="200m"
#
#
#=item ASSEMBLY_METHOD
#
# The method you would like to employ to combine your file system into an
Expand Down Expand Up @@ -606,6 +630,16 @@ if isEnabled "$CREATE_LVM_SNAPSHOT"; then
if ! [ -d "$SNAPSHOT_DIR" ]; then
cleanup 1 "Snapshot directory '$SNAPSHOT_DIR' not found."
fi

# Check if we have to use kpartx
if isEnabled "$KPARTX"; then
if [ -z "$KPARTX_PARTITION" ]; then
cleanup 1 "KPARTX_PARTITION is mandantory when using partx"
fi

requireCommand partx || cleanup 1

fi
fi

constructFilename() {
Expand Down Expand Up @@ -850,9 +884,18 @@ if isEnabled "$CREATE_LVM_SNAPSHOT"; then
# and another hook
hook POST_FREEZE
# mount the new volume

if isEnabled "$KPARTX"; then
mkdir -p "$SNAPSHOT_DIR/$LVM_MOUNT_DIR" || cleanup 1 "Unable to create mountpoint"
kpartx -av ${LVM_VOLUME_NAME}_snap
mount $LVM_MOUNT_OPTIONS "$KPARTX_PARTITION" "$SNAPSHOT_DIR/$LVM_MOUNT_DIR" || cleanup 1 "Unable to mount snapshot"
BASEDIR="$SNAPSHOT_DIR"
else

mkdir -p "$SNAPSHOT_DIR/$LVM_MOUNT_DIR" || cleanup 1 "Unable to create mountpoint"
mount $LVM_MOUNT_OPTIONS "$SNAPDEV" "$SNAPSHOT_DIR/$LVM_MOUNT_DIR" || cleanup 1 "Unable to mount snapshot"
BASEDIR="$SNAPSHOT_DIR"
fi
fi

# Construct excludes for find
Expand Down