Fix Nextcloud multipart backups being only slightly rotated
This commit is contained in:
parent
c3fa85aacb
commit
3a33549174
@ -29,11 +29,16 @@ chmod 770 "$OUTDIR"
|
||||
|
||||
# Purge oldest backup if we need to
|
||||
currentbackupcount="$(ls -1 "$OUTDIR" | wc -l)"
|
||||
if (( currentbackupcount >= retention )); then
|
||||
lastbackup="$(find "$OUTDIR" -name \*.zip 2>/dev/null | sort | head -n 1)"
|
||||
if [ -f "$lastbackup" ]; then
|
||||
log "Removing old backup: $lastbackup"
|
||||
rm "$lastbackup"
|
||||
# Multiplying by three here because our backups are three-parters
|
||||
if (( currentbackupcount >= retention * 3 )); then
|
||||
lastbackup="$(find "$OUTDIR" -name \*.tar.gz 2>/dev/null | sort | head -n 1)"
|
||||
lastbackup="${lastbackup%-*.gz}"
|
||||
if [ -f "$file" ]; then
|
||||
log "Removing old backups for: $lastbackup"
|
||||
for file in "$OUTDIR"/"$lastbackup"*; do
|
||||
log "Removing old backup part: $file"
|
||||
rm "$file"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
# WE MAKE BACKUP NOW SERGEI
|
||||
|
Loading…
Reference in New Issue
Block a user