Commit de720ecf authored by Darko Poljak's avatar Darko Poljak

If renaming oldest bak dir fails then fallback to removing it

parent e44dede9
......@@ -734,14 +734,17 @@ while [ "${source_no}" -lt "${no_sources}" ]; do
oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \
_exit_err "Listing oldest backup failed")
_techo "Using ${oldest_bak} for destination dir ${destination_dir}"
mv "${oldest_bak}" "${destination_dir}" ||
_exit_err "Moving oldest backup ${oldest_bak} to ${destination_dir} failed."
# Touch dest dir so it is not sorted wrong in listings below.
touch "${destination_dir}"
if mv "${oldest_bak}" "${destination_dir}"; then
# Touch dest dir so it is not sorted wrong in listings below.
touch "${destination_dir}"
# We have something to remove only if count > interval.
if [ "${count}" -gt "${c_interval}" ]; then
# We have something to remove only if count > 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)..."
ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment