rotate_folder now correctly handles "zero elements to keep" directives.
This commit is contained in:
@@ -55,6 +55,8 @@
|
|||||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
# 2025-09-15 v1.3
|
||||||
|
# fix: now correctly handles "zero elements to keep" directives.
|
||||||
# 2025-08-12 v1.2
|
# 2025-08-12 v1.2
|
||||||
# fix: now correctly handles configuration file pathnames containing spaces.
|
# fix: now correctly handles configuration file pathnames containing spaces.
|
||||||
# 2025-03-06 v1.1
|
# 2025-03-06 v1.1
|
||||||
@@ -304,6 +306,7 @@ function rotate_class {
|
|||||||
# This week concluded.
|
# This week concluded.
|
||||||
done
|
done
|
||||||
# The weekly schedule concluded.
|
# The weekly schedule concluded.
|
||||||
|
if [[ "$RETAIN_WEEKS" -ge 1 ]]; then
|
||||||
# If we didn't save any file within this schedule we'll retain this file.
|
# If we didn't save any file within this schedule we'll retain this file.
|
||||||
if [[ -z "$last_retained" && $pointer -lt ${#class_files[@]} ]]; then
|
if [[ -z "$last_retained" && $pointer -lt ${#class_files[@]} ]]; then
|
||||||
last_retained="$file_mtime"
|
last_retained="$file_mtime"
|
||||||
@@ -312,6 +315,7 @@ function rotate_class {
|
|||||||
[[ $pointer -lt ${#class_files[@]} ]] \
|
[[ $pointer -lt ${#class_files[@]} ]] \
|
||||||
&& file_mtime=$("$STAT" -c %Y "$BACKUP_FOLDER/${class_files[$pointer]}")
|
&& file_mtime=$("$STAT" -c %Y "$BACKUP_FOLDER/${class_files[$pointer]}")
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# The monthly schedule.
|
# The monthly schedule.
|
||||||
# We'll retain only the oldest file from a month within this schedule.
|
# We'll retain only the oldest file from a month within this schedule.
|
||||||
@@ -348,6 +352,7 @@ function rotate_class {
|
|||||||
# This month concluded.
|
# This month concluded.
|
||||||
done
|
done
|
||||||
# The monthly schedule concluded.
|
# The monthly schedule concluded.
|
||||||
|
if [[ "$RETAIN_MONTHS" -ge 1 ]]; then
|
||||||
# If we didn't save any file within this schedule we'll retain this file.
|
# If we didn't save any file within this schedule we'll retain this file.
|
||||||
if [[ -z "$last_retained" && $pointer -lt ${#class_files[@]} ]]; then
|
if [[ -z "$last_retained" && $pointer -lt ${#class_files[@]} ]]; then
|
||||||
last_retained="$file_mtime"
|
last_retained="$file_mtime"
|
||||||
@@ -356,6 +361,7 @@ function rotate_class {
|
|||||||
[[ $pointer -lt ${#class_files[@]} ]] \
|
[[ $pointer -lt ${#class_files[@]} ]] \
|
||||||
&& file_mtime=$("$STAT" -c %Y "$BACKUP_FOLDER/${class_files[$pointer]}")
|
&& file_mtime=$("$STAT" -c %Y "$BACKUP_FOLDER/${class_files[$pointer]}")
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# All the schedules have been processed.
|
# All the schedules have been processed.
|
||||||
# The remaining files will be deleted all.
|
# The remaining files will be deleted all.
|
||||||
|
Reference in New Issue
Block a user