Skip to content

Include uploaded images in user backup and restore - #3475

Open
magicbug wants to merge 2 commits into
devfrom
fix/backup-image-restore
Open

magicbug wants to merge 2 commits into
devfrom
fix/backup-image-restore

Conversation

@magicbug

@magicbug magicbug commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • User ZIP backups now include QSL, eQSL, SSTV and diary images, and restore their associations after record IDs change. Station-to-logbook relationships are preserved. This is the work from Include uploaded images in user backup and restore #3474 with the review findings fixed.
  • A failed restore deletes the QSO and image rows it inserted. Those tables are MyISAM on existing installs, so a database transaction does not remove them. Database debug mode is turned off for the restore so a query error cannot exit before that cleanup.
  • Diary titles and bodies are sanitized before they are stored. Restored images use a filename unique to the destination record, existing matching files are reused, BMP SSTV images are included, and diary [image:ID] shortcodes are remapped.

Test plan

  • docker exec cloudlog-web-1 php tests/backup_files_test.php
  • Import a backup that contains a QSL image into the account that already owns it, and confirm the image is not duplicated
  • Import the same backup into another account and confirm the diary image shortcode still shows the picture
  • Restore a logbook without its station and confirm the QSOs are reported as skipped
  • Close Include uploaded images in user backup and restore #3474 when this is merged

Made with Cursor

AlanFarley and others added 2 commits October 3, 2026 11:26
User ZIP backups currently contain stations, logbooks and QSOs but omit their uploaded images. This change includes QSL, eQSL, SSTV and diary images, and restores their associations after record IDs change. It also preserves station-to-logbook relationships.

The new schema (1.1) records attachment paths and SHA-256 checksums. Imports validate image formats, checksums and size limits, reuse existing records and attachments, and use a database transaction with cleanup of newly created files on failure. Diary entries with images can be restored optionally; newly created diary entries are private. Older backups without attachments remain supported.

The preview displays attachment counts and missing-source-file notices; the result displays the number of restored attachments. No database migration or update-script changes are required.

Validation:
- php tests/backup_files_test.php: passed (temporary database tables and temporary files).
- PHP syntax checks: passed for the controller, model, three views and test.
- git diff --check: passed.
- Cypress and browser JavaScript validation: pending; Cypress is not installed locally and existing specs do not cover backup.

Limitations:
- Only diary entries with available image attachments are included.
- Images increase archive size and restore duration; server upload limits still apply.
- Import limits: 256 MiB JSON in ZIP, 100 MiB per image, 2 GiB total image data, 100,000 attachment references.
- Review and browser validation are still required before publication.
QSO and QSL image tables are MyISAM, so the restore now deletes its own inserts when it fails. Diary HTML is sanitized, and each restored image keeps its own file and diary shortcode.
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.

2 participants