Newer
Older
function mount_ro {
# remount backup destination as read-only
if [ "$dest" == "local" ]; then
if [ "$read_only" == "1" ] || [ "$read_only" == "yes" ]; then
mount -o remount,ro $mountpoint
fi
fi
}

micah
committed
# check partition for errors
if [ "$dest" == "local" ]; then
if [ "$fscheck" == "1" ] || [ "$fscheck" == "yes" ]; then
umount $mountpoint
warning "Could not umount $mountpoint to run fsck"
else
$nice $fsck -v -y $partition >> $log
mount $mountpoint

micah
committed
# sane permission on backup
mkdir -p $backupdir/$VROOTDIR
chmod 000 $backupdir/$VROOTDIR
for candidate in $found_vservers; do
candidate="`basename $candidate`"
found_excluded_vserver="0"
for excluded_vserver in $exclude_vserver; do
if [ "$excluded_vserver" == "$candidate" ]; then
found_excluded_vserver="1"
break
fi
done
if [ "$found_excluded_vserver" == "0" ]; then

micah
committed
if [ "$multiconnection" == "yes" ]; then
debug "Starting master ssh connection"
$ssh_cmd -M sleep 1d &
sleep 1
fi
if [ "$multiconnection" == "yes" ]; then
debug "Stopping master ssh connection"
$ssh_cmd pkill sleep
fi
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
function set_pipefail {
# Save initial pipefail status for later restoration
if echo "$SHELLOPTS" | grep -q ":pipefail"; then
pipefail="-o"
else
pipefail="+o"
fi
# Ensure that a non-zero rsync exit status is caught by our handler
set -o pipefail
}
function restore_pipefail {
if [ ! -z "$pipefail" ]; then
set $pipefail pipefail
fi
}
function check_rsync_exit_status {
if [ -z "$1" ]; then
return
fi
case $1 in
1|2|3|4|5|6|10|11|12|13|14|21)
fatal "Rsync error $1 when trying to transfer $SECTION"
;;
*)
warning "Rsync error $1 when trying to transfer $SECTION"
;;
esac
}
eval_config
set_rsync_options
start_mux
stop_services
mount_rw

micah
committed

rhatto
committed
starttime="`date +%c%n%s`"
echo "Starting backup at `echo "$starttime" | head -n 1`" >> $log

micah
committed
prepare_storage
set_orig
set_batch_mode
set_filelist
set_dest

intrigeri
committed
debug $nice $rsync ${rsync_options[@]} $filelist_flag $excludes $batch_option $orig $dest_path

intrigeri
committed
$nice su -c "$rsync ${rsync_options[@]} --delete-excluded $filelist_flag $excludes $batch_option $orig $dest_path" | tee -a $log

micah
committed
check_rsync_exit_status $?

micah
committed
mount_ro
run_fsck
start_services
end_mux
echo "Finnishing backup at `date`" >> $log