feat: refs #8869 remove previous differential backup
This commit is contained in:
parent
9c2ff170a0
commit
61da00046e
roles/db/files/mariabackup
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue