feat: refs #8869 remove previous differential backup

This commit is contained in:
Juan Ferrer 2025-04-06 21:12:32 +02:00
parent 9c2ff170a0
commit 61da00046e
1 changed files with 6 additions and 3 deletions
roles/db/files/mariabackup

View File

@ -10,7 +10,7 @@ myDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
level=$1
historyName=$2
todayDir="$(date +%Y-%m-%d)"
curDate="$(date +%Y-%m-%d)"
usage() {
echo "Usage: $0 <Full|Differential|Incremental> [historyName]"
@ -27,7 +27,7 @@ fi
case "$level" in
Full)
backupName="${todayDir}_$(date +"%H-%M")_full"
backupName="${curDate}_$(date +"%H-%M")_full"
backupFile="$backupDir/$backupName.gz"
if [ -d "$backupDir" ]; then
@ -54,7 +54,7 @@ case "$level" in
fi
;;
Differential|Incremental)
pattern="$backupDir/${todayDir}_??-??_full.gz"
pattern="$backupDir/${curDate}_??-??_full.gz"
files=($pattern)
backupFile="${files[0]}"
backupBase=$(basename -- "$backupFile")
@ -63,6 +63,9 @@ case "$level" in
incrementalName="${backupName%%_full}_diff_$(date +"%H-%M")"
incrementalFile="$backupDir/${incrementalName}.gz"
if [ "$level" = "Differential" ]; then
rm -rf "$backupDir/${curDate}_"??-??_diff_??-??
fi
if [ -z "$historyName" ]; then
historyName=$incrementalName
fi