Fix newly introduced bug (absdir/destination)
add absolute directory for --link-dest, because rsync does chdir() before beginnig backup
This commit is contained in:
parent
e6614294c2
commit
342b5bf488
1 changed files with 17 additions and 11 deletions
28
ccollect.sh
28
ccollect.sh
|
@ -15,7 +15,7 @@ CPOSTEXEC="$CDEFAULTS/post_exec"
|
||||||
|
|
||||||
TMP=$(mktemp /tmp/$(basename $0).XXXXXX)
|
TMP=$(mktemp /tmp/$(basename $0).XXXXXX)
|
||||||
VERSION=0.5
|
VERSION=0.5
|
||||||
RELEASE="2006-XX-XX"
|
RELEASE="2006-10-15"
|
||||||
HALF_VERSION="ccollect $VERSION"
|
HALF_VERSION="ccollect $VERSION"
|
||||||
FULL_VERSION="ccollect $VERSION ($RELEASE)"
|
FULL_VERSION="ccollect $VERSION ($RELEASE)"
|
||||||
|
|
||||||
|
@ -380,17 +380,14 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
# give some info
|
# give some info
|
||||||
echo "Beginning to backup, this may take some time..."
|
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!
|
# make an absolute path, perhaps $CCOLLECT_CONF is relative!
|
||||||
#
|
#
|
||||||
abs_destination_dir="$(cd $destination_dir && pwd -P)"
|
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
|
# the rsync part
|
||||||
# options partly stolen from rsnapshot
|
# options partly stolen from rsnapshot
|
||||||
|
@ -398,19 +395,28 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
|
|
||||||
echo "$($DDATE) Transferring files..."
|
echo "$($DDATE) Transferring files..."
|
||||||
|
|
||||||
set -x
|
|
||||||
|
|
||||||
ouropts="-a --delete --numeric-ids --relative --delete-excluded"
|
ouropts="-a --delete --numeric-ids --relative --delete-excluded"
|
||||||
useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA"
|
useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA"
|
||||||
|
|
||||||
# Clone from previous backup, if existing
|
# Clone from previous backup, if existing
|
||||||
|
set -x
|
||||||
if [ "$last_dir" ]; then
|
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"
|
rsync $ouropts "$rsync_hardlink" $useropts "$source" "$abs_destination_dir"
|
||||||
else
|
else
|
||||||
rsync $ouropts $useropts "$source" "$abs_destination_dir"
|
rsync $ouropts $useropts "$source" "$abs_destination_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
|
|
Loading…
Reference in a new issue