Fix newly introduced bug (absdir/destination)

add absolute directory for --link-dest, because rsync does chdir()
before beginnig backup
This commit is contained in:
Nico Schottelius 2006-10-15 17:12:39 +02:00
parent e6614294c2
commit 342b5bf488
1 changed files with 17 additions and 11 deletions

View File

@ -15,7 +15,7 @@ CPOSTEXEC="$CDEFAULTS/post_exec"
TMP=$(mktemp /tmp/$(basename $0).XXXXXX)
VERSION=0.5
RELEASE="2006-XX-XX"
RELEASE="2006-10-15"
HALF_VERSION="ccollect $VERSION"
FULL_VERSION="ccollect $VERSION ($RELEASE)"
@ -380,17 +380,14 @@ while [ "$i" -lt "$no_sources" ]; do
# give some info
echo "Beginning to backup, this may take some time..."
echo "Creating $destination_dir ..."
mkdir $VVERBOSE "$destination_dir"
#
# make an absolute path, perhaps $CCOLLECT_CONF is relative!
#
abs_destination_dir="$(cd $destination_dir && pwd -P)"
if [ ! "abs_destination_dir" ]; then
echo "Could
echo "Creating $abs_destination_dir ..."
mkdir $VVERBOSE "$abs_destination_dir"
#
# the rsync part
# options partly stolen from rsnapshot
@ -398,19 +395,28 @@ while [ "$i" -lt "$no_sources" ]; do
echo "$($DDATE) Transferring files..."
set -x
ouropts="-a --delete --numeric-ids --relative --delete-excluded"
useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA"
# Clone from previous backup, if existing
set -x
if [ "$last_dir" ]; then
rsync_hardlink="--link-dest=$last_dir"
#
# This directory MUST be absolute, because rsync does chdir()
# before beginning backup!
#
abs_last_dir="$(cd "$last_dir" && pwd -P)"
if [ -z "$abs_last_dir" ]; then
echo "Changing to the backup destination failed. I skip this backup."
exit 1
fi
rsync_hardlink="--link-dest=$abs_last_dir"
rsync $ouropts "$rsync_hardlink" $useropts "$source" "$abs_destination_dir"
else
rsync $ouropts $useropts "$source" "$abs_destination_dir"
fi
set +x
if [ "$?" -ne 0 ]; then