Skip to content

Backup: tar bei geänderter Datei während des Lesens wiederholen - #4366

Open
seaspotter wants to merge 1 commit into
openWB:masterfrom
seaspotter:fix-backup-tar-file-changed
Open

seaspotter wants to merge 1 commit into
openWB:masterfrom
seaspotter:fix-backup-tar-file-changed

Conversation

@seaspotter

@seaspotter seaspotter commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

tar beendet sich mit Status 1, wenn sich eine Datei während des Lesens ändert. Das passiert beim Tageslog (data/daily_log), das alle 5 Minuten neu geschrieben wird. Wegen set -e bricht dann das ganze Backup ab ("backup failed at line 225"), obwohl das Archiv fertig erstellt wurde. Das Verhalten ist in #4342 beschrieben.

Änderungen:

  • Der tar-Aufruf ist in eine Funktion gekapselt und wird bei Status 1 bis zu dreimal wiederholt, jeweils mit einer Warnung im Log.
  • Endet auch der dritte Lauf mit Status 1, wird mit einer Warnung fortgefahren und das letzte Archiv verwendet.
  • Ab Status 2 schlägt das Backup weiterhin fehl.
  • Getestet auf einer openWB (2.4.0-alpha.1): Beim ersten tar-Lauf trat die Warnung auf, der zweite Lauf war sauber und das Backup wurde erfolgreich abgeschlossen.

Fixes #4342

Summary by Sourcery

Make backups resilient to files changing during tar archive creation without masking genuine archive errors.

Bug Fixes:

  • Retry archive creation up to three times when tar reports that a file changed while it was being read, allowing backups to complete despite transient log-file updates.

Enhancements:

  • Continue using the last archive with a warning after three such tar failures, while still failing the backup for other tar errors.

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Linked issues

Checked at commit f614a32

#4342 [BUG] 2.3.0 automatische Backups weren nicht mehr durchgeführt, manuelle funktionieren · 1 of 1 met

# Requirement Status Notes
1 Automatische Backups wieder durchführen können ✅ Met Der Backup-Pfad behandelt tar-Status 1 nun als vorübergehenden Fehler: Er wiederholt den Archivlauf bis zu dreimal und fährt nach drei solchen Läufen mit dem letzten Archiv fort.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="runs/backup.sh" line_range="254-257" />
<code_context>
+		local attempt
+		for attempt in 1 2 3; do
+			tarStatus=0
+			tar_create || tarStatus=$?
+			((tarStatus == 1)) || break
+			echo "warning: tar reported a file that changed while reading (attempt $attempt of 3)"
+		done
+		if ((tarStatus == 1)); then
+			echo "warning: continuing with the last archive, a file changed while it was read"
</code_context>
<issue_to_address>
**Concurrent backups overwrite each other**

When two backup requests overlap and choose the same filename, a second backup process can write the same `BACKUPFILE` while the first is retrying; the first retry recreates that path, so either process can append, checksum, or compress the other’s archive and return a misleading success or a missing file.

Serialize backup runs or give each process a unique temporary archive path and publish it only after the complete backup succeeds.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread runs/backup.sh Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 2.3.0 automatische Backups weren nicht mehr durchgeführt, manuelle funktionieren

1 participant