Refactor the core backup and encryption logic to use a new, consistent directory structure. This new structure separates encrypted and unencrypted backups and centralizes metadata, making the system more robust and easier to manage.
Key changes:
- Implemented a new directory scheme:
/pybackup/
├── unencrypted/{system,user}/<source>/
├── encrypted/{system,user}/<source>/ (mount point)
├── metadata/
└── pybackup_encrypted.luks
- Reworked path generation logic in BackupManager and EncryptionManager to support the new structure.
- All backup, restore, and listing operations now correctly resolve paths based on the new scheme.
This also includes several bug fixes identified during the refactoring:
- fix(backup): Correctly quote rsync paths for user backups to prevent "No such file or directory" errors.
- fix(encryption): Change key lookup order to Keyring -> Keyfile -> Password Prompt, as requested.
- fix(ui): Remove eager auto-mount on startup to prevent unexpected password prompts. The app now only mounts when required by a user action.
This commit introduces several UI enhancements and bug fixes based on user feedback.
- **Backup Content View:**
- The "Folder" column is now displayed before the "Comment" column for user backups.
- The "Folder" column now shows the simple source name (e.g., "Dokumente") instead of the full backup name.
- Column alignment and widths have been adjusted in both system and user backup views for better readability.
- A timing issue causing progress bars to be missing after unlocking an encrypted volume has been resolved.
- **Advanced Settings:**
- New options have been added to control file deletion behavior (use trash or delete directly).
- The layout of the advanced settings panel has been refined.
- **Encryption:**
- Introduces a keyfile-based authentication mechanism for LUKS containers, reducing the need for password prompts.
- Replaces temporary script files with a dedicated runner script (`privileged_script_runner.sh`) for executing root commands, improving security and robustness.
This commit refactors the encrypted container management to significantly improve usability and robustness.
- **Reduced Password Prompts:** The entire resize operation (unmount, truncate, check, resize, mount) is now consolidated into a single script. This reduces the maximum number of password prompts during a backup with resize from four down to two.
- **Fix "No Space Left" Error:** The resize script is now more robust, including a filesystem check (`e2fsck`) before resizing to prevent the filesystem from failing to expand. This resolves the critical "No space left on device" error.
- **Session-wide Password Cache:** A simple in-memory cache for the LUKS password has been introduced. This prevents further password prompts when unmounting containers, for example, when the application is closed.
- **Improved Logging:** Privileged script execution now logs stderr output even on success, aiding future diagnostics.
This commit addresses several bugs related to the mounting, unmounting, and deletion of encrypted backups, as well as a crash when listing backups.
The key changes are:
- **Fix Double Mount on View:** Removed redundant mount operation when viewing encrypted backup contents. The mount is now handled by a single, centralized function.
- **Fix Deletion of Encrypted Backups:**
- The container is no longer re-mounted if already open, preventing a second password prompt.
- Deletion of encrypted *user* backups is now performed with user-level permissions, removing the need for a third password prompt via pkexec.
- **Fix UI Refresh after Deletion:** The backup list now correctly refreshes after a backup is deleted.
- **Fix Crash on Empty Backup List:** Resolved an `UnboundLocalError` that occurred when listing backups from an empty or non-existent backup directory.
- **Improve Mount Detection:** The `is_mounted` check is now more robust to prevent race conditions or other OS-level inconsistencies.
Replaced the LVM-on-a-file implementation with a more robust, industry-standard LUKS-on-a-file approach.
This change was motivated by persistent and hard-to-debug errors related to LVM state management and duplicate loop device detection during repeated mount/unmount cycles.
The new implementation provides several key benefits:
- **Robustness:** Eliminates the entire LVM layer, which was the root cause of the mount/unmount failures.
- **Improved UX:** Drastically reduces the number of password prompts for encrypted user backups. By changing ownership of the mountpoint, rsync can run with user privileges.
- **Enhanced Security:** The file transfer process (rsync) for user backups no longer runs with root privileges.
- **Better Usability:** Encrypted containers are now left mounted during the application's lifecycle and are only unmounted on exit, improving workflow for consecutive operations.
This commit introduces the core logic for handling incremental user backups.
Changes include:
- Updated `core/backup_manager.py`:
- Modified `_list_user_backups_from_path` to parse new naming convention for user backups (including `_full` and `_incremental`).
- Enhanced `_find_latest_backup` to filter by source name for user backups.
- Adjusted `_run_backup_path` to dynamically determine backup mode (full/incremental) for user backups and apply `--link-dest` accordingly.
- Updated `pyimage_ui/user_backup_content_frame.py`:
- Added `tag_colors` attribute for visual differentiation.
- Included 'type' column in the Treeview.
- Modified `_load_backup_content` to apply coloring based on backup type.
This commit introduces significant improvements to how encrypted backups are handled,
focusing on user experience and system integration.
- Persistent Mounts: Encrypted backup containers now remain mounted across UI view changes,
eliminating repeated password prompts when navigating the application. The container is
automatically unmounted when the destination changes or the application closes.
- Key Management Fallback: The mounting process now intelligently falls back from
keyring to keyfile, and finally to a user password prompt if previous methods fail.
- Enhanced UI Status: The header now provides detailed feedback on the encryption key
status, indicating whether a key is available (via keyring or keyfile) and if the
container is currently in use.
- Reduced pkexec Prompts: By keeping containers mounted, the number of system-level
pkexec authentication prompts is drastically reduced, improving workflow.
- Bug Fixes:
- Corrected a SyntaxError in encryption_manager.py related to string escaping.
- Fixed an AttributeError in header_frame.py by restoring the is_key_in_keyring method.
- Addressed a TclError on application shutdown by safely destroying Tkinter widgets.
Adds logic to prevent the screensaver or screen lock from activating while a backup is in progress.
- Uses a D-Bus call to `org.freedesktop.ScreenSaver.Inhibit` to request a lock.
- The lock is activated when a backup starts.
- The lock is reliably released when the backup finishes, fails, or is cancelled.
Refactors the encryption mechanism to use a flexible LVM-on-a-loop-device backend instead of a fixed-size file. This resolves issues with containers running out of space.
- Implements auto-resizing of the container when a backup fails due to lack of space.
- Implements transparent inspection of encrypted containers, allowing the UI to display their contents (full/incremental backups) just like unencrypted ones.
- Fixes deletion of encrypted backups by ensuring the container is unlocked before deletion.
- Fixes a bug where deleting unencrypted user backups incorrectly required root privileges.
- Fixes a UI freeze caused by calling a password dialog from a non-UI thread during deletion.
- Simplifies the UI by removing the now-obsolete "Show Encrypted Backups" button.
- Changes the default directory for encrypted user backups to `user_encrypt`.
Die Logik zur Erkennung von vollständigen Backups wurde verbessert.
Das Programm prüft nun korrekt, ob bereits ein vollständiges Backup
vorhanden ist und schlägt in diesem Fall automatisch ein inkrementelles
Backup vor. Dies funktioniert jetzt auch für verschlüsselte Backups.
- Introduces `pybackup-cli.py` as a command-line interface for non-interactive backups.
- Adds support for LUKS key files in `EncryptionManager` for passwordless container operations.
- Updates `BackupManager` to pass key file arguments to encryption routines.
- Modifies `AdvancedSettingsFrame` to provide a GUI for creating and managing key files.
- Integrates `pybackup-cli.py` and key file options into `schedule_job_dialog.py` for cronjob generation.
- Fixes a bug where the backup list would not display "orphan" incremental backups in the encrypted view.
- Fixes a bug where system backups were incorrectly shown in the user backup list.
- Prevents the app from asking for system permissions to lock an encrypted container on exit if it is not currently mounted.
- Fixes pathing inconsistencies for the encryption manager to ensure mapper names are created consistently.
- Adds debug logging to the backup list functions to help diagnose future issues.
- Centralizes backup content view logic into a single BackupContentFrame.
- Removes the separate, now obsolete EncryptedBackupContentFrame.
- Adds a toggle button within the BackupContentFrame to switch between viewing normal and encrypted backups.
- Centralizes the Restore, Delete, and Edit Comment buttons into a single button bar in BackupContentFrame.
- Corrects the path resolution logic to find backups and encrypted containers within the /pybackup subdirectory.
- Fixes UI bugs where action buttons would disappear when switching tabs.
- Improves the backup list display with chronological sorting, colored grouping for full/incremental backups, and dedicated time column.
- Changes backup folder naming to a consistent dd-mm-yyyy_HH:MM:SS format.
- Fixes bug where backup size was not displayed.
- Adds detection for encrypted backup containers, showing them correctly in the list.
- Hardens destination space check:
- Considers extra space needed for compressed backups.
- Disables start button if projected usage is > 95% or exceeds total disk space.
- Refactor '_execute_rsync', um die 'Gesamtgröße' aus der rsync-Ausgabe zu parsen und zurückzugeben, was eine genauere Größe für vollständige Backups liefert.
- Verbessertes Logging im Backup-Manager, um die Ausführung von rsync und die Logik zur Größenberechnung besser zu verfolgen.
- Implementierung eines live aktualisierenden Dauer-Timers auf der Haupt-UI, der die verstrichene Zeit während eines Backup-Vorgangs anzeigt.
- Die Zusammenfassung am Ende des Backups verwendet nun die genaueren Größeninformationen.
Mehrere grundlegende Probleme in der Anwendungslogik wurden behoben:
- **UI-Verarbeitungsschleife:** Die Verarbeitung von Nachrichten aus Hintergrund-Threads wurde komplett überarbeitet. Zuvor führten zwei konkurrierende Schleifen zu einer Race Condition, bei der Nachrichten verloren gingen. Jetzt gibt es eine einzige, zentrale Verarbeitungsschleife, die Nachrichten in Stapeln verarbeitet. Dies behebt das Problem, dass die Benutzeroberfläche nach dem Löschen oder dem Abschluss eines Backups im "in Arbeit"-Zustand hängen blieb.
- **Backup-Grössenberechnung:** Die Ermittlung der Grösse von inkrementellen Backups wurde robuster gestaltet.
- Die rsync-Ausgabe wird nun zuverlässig auf Englisch erzwungen, um Parsing-Fehler in anderen System-Locales zu vermeiden.
- Die Grösse wird nun aus der `sent... received...` Zusammenfassungszeile von rsync ausgelesen, was auch bei Backups ohne Datenänderungen einen Wert ungleich Null liefert.
- Es wird nun korrekt zwischen Voll-Backups (Anzeige der Gesamtgrösse) und inkrementellen Backups (Anzeige der Übertragungsgrösse) unterschieden.
- **Sonstige Korrekturen:**
- Eine fehlende Übersetzung für die manuelle Ausschlussliste wurde hinzugefügt.
- Ein überflüssiger Aufruf zum Starten der Verarbeitungsschleife wurde entfernt.
- Update button styles in Backup Content and Advanced Settings to match the main application navigation.
- Implement a progress bar indicator for the active tab.
- Realign buttons in Advanced Settings to the left.
- Add a dynamic informational label for the "Manual Excludes" section.
- Ensure backup content view updates after backup completion or deletion.
- Fix "Please wait" animation not stopping after backup deletion.
- Refactor backup type selection logic for more reliable UI updates.
- Correct backup detection after resetting settings.
- Ensure correct size is written to info file for all backup types.
- Create a separate file for manual excludes (`rsync-manual-excludes.conf`) that is not cleared on reset.
- Add a button to the settings frame to add files/folders to the manual exclude list.
- Update the backup and calculation logic to use the manual exclude list.
- Ensure the UI reflects the combined exclude lists.
This commit includes updates across several modules, including:
- backup_manager.py: Enhancements related to backup deletion and regex for backup naming.
- core/data_processing.py: Adjustments to UI state handling.
- pbp_app_config.py: Addition of new UI messages.
- pyimage_ui/actions.py: Refinements in UI actions.
- pyimage_ui/system_backup_content_frame.py: Integration of new deletion logic.
- pyimage_ui/user_backup_content_frame.py: Minor adjustments.
These changes collectively improve backup management, UI responsiveness, and prepare for new deletion features.
Corrected the parenting of BackupContentFrame in main_app.py to ensure it's a child of content_frame, aligning its layout behavior with SettingsFrame.
Resolved AttributeError in BackupContentFrame by updating style lookup to use the top-level window's style object, ensuring correct background color retrieval.
Implements a new feature for creating compressed full backups and restoring from them.
- Backups can now be created as compressed .tar.gz archives.
- This option is only available for full backups to maintain the efficiency of incremental backups.
- The UI now forces a full backup when compression is selected.
- The backup list correctly identifies and labels compressed backups.
- The restore process can handle both compressed and uncompressed backups.
fix: Improve backup process feedback and reliability
- Fixes a critical bug where backups could be overwritten if created on the same day. Backup names now include a timestamp to ensure uniqueness.
- Improves UI feedback during compressed backups by showing distinct stages (transfer, compress) and using an indeterminate progress bar during the compression phase.
- Disables the cancel button during the non-cancellable compression stage.
- Fixes a bug where the incremental backup size was written to the info file for full backups. The correct total size is now used.
This commit introduces two main improvements:
1. **Backup Deletion:** The user can now delete system and user backups from the "Backup Content" view.
2. **Improved Exclusion List:** The `.cache` directory is now excluded from backups by default, which should prevent "file has vanished" warnings from rsync.
2
3 Dieses Commit enthält zwei wesentliche Verbesserungen:
4
5 1. **Flexible Auswahl des Backup-Typs:** Der Benutzer kann jetzt manuell die
Erstellung eines vollständigen Backups auswählen, auch wenn bereits ein früheres
vollständiges Backup vorhanden ist. Die Anwendung wechselt in diesem Fall nicht mehr
automatisch zu einem inkrementellen Backup.
6
7 2. **Korrektur der Füllstandsanzeige:** Die Füllstandsanzeige zeigt jetzt die
voraussichtliche Backup-Größe sowohl für vollständige als auch für inkrementelle
Backups korrekt an. Dies wurde erreicht, indem sichergestellt wurde, dass die
Quellgröße in allen Fällen korrekt berechnet und an die Benutzeroberfläche übergeben
wird.
- Ändert die Logik zum Erstellen und Auflisten von Backups, um Metadaten-Dateien (z.B. 'backup_name.txt') im übergeordneten Verzeichnis des Backups statt darin zu speichern.
- Dies behebt den 'Permission denied'-Fehler beim Schreiben von Metadaten für System-Backups, die root gehören, da das übergeordnete Verzeichnis für den Benutzer beschreibbar ist.
- Ermöglicht vollständig unbeaufsichtigte/automatisierte Backups ohne eine zweite Passwortabfrage.
- Behebt das Problem, bei dem für die Metadaten-Datei eine zweite pkexec-Passwortabfrage nach einem langen Backup-Lauf erforderlich war. Dies ermöglicht nun unbeaufsichtigte/automatisierte Backups.
- Fügt eine neue UI-Anzeige für Startzeit, Endzeit und Dauer des Backups hinzu.
- Das Info-Label zeigt nun den prozentualen Fortschritt während des Backups an.
This commit refactors the backup cancellation process and hardens the UI state
management to resolve several race conditions and bugs.
Key changes:
Atomic Privileged Operations:
Introduced a helper method (`_execute_as_root`) to run shell commands via a
temporary script with a single `pkexec` invocation.
The backup cancellation for system backups now uses this method to atomically
terminate the rsync process and delete the partial backup directory, requiring only
one password authentication instead of two.
A general-purpose `delete_privileged_path` method is now available for other UI
actions, like deleting from the backup content view.
Robust State Handling:
Replaced unreliable state tracking based on UI widget text with a dedicated
`self.app.backup_is_running` boolean flag.
This flag is set immediately when a backup starts, preventing a race condition
that allowed a second backup to be initiated, which previously led to a
segmentation fault.
The `toggle_start_cancel` logic is now driven entirely by this reliable in
memory flag.
UI Hardening & Bug Fixes:
The `_set_ui_state` method now also disables clicks on the destination canvas
during a backup.
The `toggle_mode` method (for switching views) now checks the
`backup_is_running` flag to prevent resetting UI elements like projection canvases
when navigating away and back during a backup.
Fixed a bug where an invalid date format string (`% -d`) created incorrect
directory names, causing the deletion on cancel to fail.
Resolved a race condition where the backup process object was cleared
prematurely, leading to an `AttributeError` in the backup thread upon cancellation.