diff --git a/ccollect.sh b/ccollect.sh index d6831bc..2b67ba7 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -281,7 +281,8 @@ while [ "${i}" -lt "${no_sources}" ]; do c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do + for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ + remote_host rsync_failure_codes ; do if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then eval c_$opt=\"${backup}/$opt\" else @@ -530,16 +531,31 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Transferring files..." rsync "$@" "${source}" "${destination_full}"; ret=$? - - # - # remove marking here - # - pcmd rm "${destination_dir}.${c_marker}" || \ - _exit_err "Removing ${destination_dir}/${c_marker} failed." - _techo "Finished backup (rsync return code: $ret)." - if [ "${ret}" -ne 0 ]; then - _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + + # + # Check if rsync exit code indicates failure. + # + fail="" + if [ -f "$c_rsync_failure_codes" ]; then + while read code ; do + if [ "$ret" = "$code" ]; then + fail=1 + fi + done <"$c_rsync_failure_codes" + fi + + # + # Remove marking here unless rsync failed. + # + if [ -z "$fail" ]; then + pcmd rm "${destination_dir}.${c_marker}" || \ + _exit_err "Removing ${destination_dir}/${c_marker} failed." + if [ "${ret}" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi + else + _techo "Warning: rsync failed with return code $ret." fi # diff --git a/doc/ccollect.text b/doc/ccollect.text index f1451f8..3d9c480 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -359,6 +359,7 @@ Additionally a source may have the following files: - `delete_incomplete` delete incomplete backups - `remote_host` host to backup to + - `rsync_failure_codes` list of rsync exit codes that indicate complete failure Example: @@ -574,6 +575,15 @@ If you create the file `delete_incomplete` in a source specification directory, was interrupted) and remove them. Without this file `ccollect` will only warn the user. +Detailed description of "rsync_failure_codes" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +If you have the file `rsync_failure_codes` in your source configuration +directory, it should contain a newline-separated list of numbers representing +rsync exit codes. If rsync exits with any code in this list, a marker will +be left in the destination directory indicating failure of this backup. If +you have enabled delete_incomplete, then this backup will be deleted during +the next ccollect run on the same interval. + Hints -----