Finish incomplete deletion in general
This commit is contained in:
parent
799c24faf3
commit
8f6a942ae9
1 changed files with 30 additions and 9 deletions
39
ccollect.sh
39
ccollect.sh
|
@ -43,7 +43,7 @@ trap "rm -f \"${TMP}\"" 1 2 15
|
||||||
# time displaying echo
|
# time displaying echo
|
||||||
_techo()
|
_techo()
|
||||||
{
|
{
|
||||||
echo "$(${DDATE}): " "$@"
|
echo "$(${DDATE}): $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# exit on error
|
# exit on error
|
||||||
|
@ -243,12 +243,16 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
||||||
c_summary="${backup}/summary"
|
c_summary="${backup}/summary"
|
||||||
c_pre_exec="${backup}/pre_exec"
|
c_pre_exec="${backup}/pre_exec"
|
||||||
c_post_exec="${backup}/post_exec"
|
c_post_exec="${backup}/post_exec"
|
||||||
c_incomplete="$backup/delete_incomplete"
|
c_incomplete="${backup}/delete_incomplete"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Marking backups: If we abort it's not removed => Backup is broken
|
||||||
|
#
|
||||||
|
c_marker=".ccollect-marker"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Times
|
# Times
|
||||||
#
|
#
|
||||||
c_marker=".ccollect-$(${CDATE}).$$"
|
|
||||||
begin_s=$(date +%s)
|
begin_s=$(date +%s)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -259,6 +263,7 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
||||||
SUMMARY=""
|
SUMMARY=""
|
||||||
VERBOSE=""
|
VERBOSE=""
|
||||||
VVERBOSE=""
|
VVERBOSE=""
|
||||||
|
DELETE_INCOMPLETE=""
|
||||||
|
|
||||||
_techo "Beginning to backup"
|
_techo "Beginning to backup"
|
||||||
|
|
||||||
|
@ -322,6 +327,16 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
||||||
_exit_err "Destination ${c_dest} is not a directory. Skipping."
|
_exit_err "Destination ${c_dest} is not a directory. Skipping."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check whether to delete incomplete backups
|
||||||
|
#
|
||||||
|
if [ -f "${c_incomplete}" ]; then
|
||||||
|
DELETE_INCOMPLETE="yes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verbosity for rsync
|
||||||
|
|
||||||
# NEW method as of 0.6:
|
# NEW method as of 0.6:
|
||||||
# - insert ccollect default parameters
|
# - insert ccollect default parameters
|
||||||
# - insert options
|
# - insert options
|
||||||
|
@ -372,14 +387,20 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
cd "${c_dest}"
|
cd "${c_dest}"
|
||||||
ls
|
# one column output to ${TMP}
|
||||||
ls "${INTERVAL}"*/.ccollect-* > "${TMP}"
|
ls -1 "${INTERVAL}"*/${c_marker} > "${TMP}"
|
||||||
|
|
||||||
|
# FIXME: debug
|
||||||
cat "${TMP}"
|
cat "${TMP}"
|
||||||
|
|
||||||
while read broken; do
|
while read incomplete; do
|
||||||
realbroken=$(echo $broken | sed 's/.ccollect-*/')
|
realincomplete=$(echo ${incomplete} | sed "s/${c_marker}\$//")
|
||||||
echo "Broken backup"
|
_techo "Incomplete backup: ${realincomplete}"
|
||||||
done
|
if [ "$DELETE_INCOMPLETE" = "yes" ]; then
|
||||||
|
_techo "Deleting ${realincomplete}"
|
||||||
|
echo rm $VVERBOSE -rf "${realincomplete}"
|
||||||
|
fi
|
||||||
|
done < "${TMP}"
|
||||||
)
|
)
|
||||||
sleep 10
|
sleep 10
|
||||||
while read incomplete; do
|
while read incomplete; do
|
||||||
|
|
Loading…
Reference in a new issue