forked from ungleich-public/ccollect
If renaming oldest bak dir fails then fallback to removing it
This commit is contained in:
parent
e44dede92f
commit
de720ecfe9
1 changed files with 9 additions and 6 deletions
9
ccollect
9
ccollect
|
@ -734,14 +734,17 @@ while [ "${source_no}" -lt "${no_sources}" ]; do
|
||||||
oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \
|
oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \
|
||||||
_exit_err "Listing oldest backup failed")
|
_exit_err "Listing oldest backup failed")
|
||||||
_techo "Using ${oldest_bak} for destination dir ${destination_dir}"
|
_techo "Using ${oldest_bak} for destination dir ${destination_dir}"
|
||||||
mv "${oldest_bak}" "${destination_dir}" ||
|
if mv "${oldest_bak}" "${destination_dir}"; then
|
||||||
_exit_err "Moving oldest backup ${oldest_bak} to ${destination_dir} failed."
|
|
||||||
# Touch dest dir so it is not sorted wrong in listings below.
|
# Touch dest dir so it is not sorted wrong in listings below.
|
||||||
touch "${destination_dir}"
|
touch "${destination_dir}"
|
||||||
|
|
||||||
# We have something to remove only if count > interval.
|
# We have something to remove only if count > interval.
|
||||||
if [ "${count}" -gt "${c_interval}" ]; then
|
|
||||||
remove="$((${count} - ${c_interval}))"
|
remove="$((${count} - ${c_interval}))"
|
||||||
|
else
|
||||||
|
_techo_err "Renaming oldest backup ${oldest_bak} to ${destination_dir} failed, removing it."
|
||||||
|
remove="$((${count} - ${c_interval} + 1))"
|
||||||
|
fi
|
||||||
|
if [ "${remove}" -gt 0 ]; then
|
||||||
_techo "Removing ${remove} backup(s)..."
|
_techo "Removing ${remove} backup(s)..."
|
||||||
|
|
||||||
ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \
|
ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \
|
||||||
|
|
Loading…
Reference in a new issue